Class: Decidim::Devise::InvitationsController

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

Overview

This controller customizes the behaviour of Devise::Invitiable.

Instance Method Summary collapse

Methods included from Decidim::DeviseControllers

#current_ability_klass

Instance Method Details

#accept_resourceObject

When a managed user accepts the invitation is promoted to non-managed user.



23
24
25
26
27
# File 'app/controllers/decidim/devise/invitations_controller.rb', line 23

def accept_resource
  resource = resource_class.accept_invitation!(update_resource_params)
  resource.update_attributes!(managed: false) if resource.managed?
  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.



18
19
20
# File 'app/controllers/decidim/devise/invitations_controller.rb', line 18

def after_accept_path_for(resource)
  params[:invite_redirect] || super
end

#authenticate_inviter!Object

We don’t users to create invitations, so we just redirect them to the homepage.



11
12
13
# File 'app/controllers/decidim/devise/invitations_controller.rb', line 11

def authenticate_inviter!
  redirect_to root_path
end