Class: Decidim::Devise::InvitationsController
- Inherits:
 - 
      Devise::InvitationsController
      
        
- Object
 - Devise::InvitationsController
 - Decidim::Devise::InvitationsController
 
 
- Includes:
 - Decidim::DeviseControllers, NeedsTosAccepted
 
- Defined in:
 - app/controllers/decidim/devise/invitations_controller.rb
 
Overview
This controller customizes the behaviour of Devise::Invitable.
Instance Method Summary collapse
- 
  
    
      #accept_resource  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
When a managed user accepts the invitation is promoted to non-managed user.
 - 
  
    
      #after_accept_path_for(resource)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Overwrite the method that returns the path after a user accepts an invitation.
 - 
  
    
      #authenticate_inviter!  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
We do not users to create invitations, so we just redirect them to the homepage.
 
Instance Method Details
#accept_resource ⇒ Object
When a managed user accepts the invitation is promoted to non-managed user.
      28 29 30 31 32 33 34 35 36 37 38  | 
    
      # File 'app/controllers/decidim/devise/invitations_controller.rb', line 28 def accept_resource resource = resource_class.accept_invitation!(update_resource_params) if resource.valid? && resource.invitation_accepted? resource.update!(newsletter_notifications_at: Time.current) if update_resource_params[:newsletter_notifications] resource.update!(managed: false) if resource.managed? resource.update!(accepted_tos_version: resource.organization.tos_version) end resource end  | 
  
#after_accept_path_for(resource) ⇒ Object
Overwrite the method that returns the path after a user accepts an invitation. Using the param ‘invite_redirect` we can redirect the user to a custom path after it has accepted the invitation.
      23 24 25  | 
    
      # File 'app/controllers/decidim/devise/invitations_controller.rb', line 23 def after_accept_path_for(resource) invite_redirect_path || after_sign_in_path_for(resource) end  | 
  
#authenticate_inviter! ⇒ Object
We do not users to create invitations, so we just redirect them to the homepage.
      16 17 18  | 
    
      # File 'app/controllers/decidim/devise/invitations_controller.rb', line 16 def authenticate_inviter! redirect_to root_path end  |