Class: Decidim::Devise::InvitationsController

Inherits:
Devise::InvitationsController
  • Object
show all
Includes:
Decidim::DeviseControllers, NeedsTosAccepted
Defined in:
app/controllers/decidim/devise/invitations_controller.rb

Overview

This controller customizes the behaviour of Devise::Invitiable.

Instance Method Summary collapse

Instance Method Details

#accept_resourceObject

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 || (resource)
end

#authenticate_inviter!Object

We don’t 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