Class: Decidim::Devise::ConfirmationsController
- Inherits:
-
Devise::ConfirmationsController
- Object
- Devise::ConfirmationsController
- Decidim::Devise::ConfirmationsController
- Includes:
- Decidim::DeviseControllers
- Defined in:
- app/controllers/decidim/devise/confirmations_controller.rb
Overview
Custom Devise ConfirmationsController to avoid namespace problems.
Instance Method Summary collapse
-
#after_confirmation_path_for(resource_name, resource) ⇒ Object
Overwrites the default method to handle user groups confirmations.
- #create ⇒ Object
-
#resource_params ⇒ Object
Since we’re using a single Devise installation for multiple organizations, and user emails can be repeated across organizations, we need to identify the user by both the email and the organization.
Instance Method Details
#after_confirmation_path_for(resource_name, resource) ⇒ Object
Overwrites the default method to handle user groups confirmations.
31 32 33 34 35 |
# File 'app/controllers/decidim/devise/confirmations_controller.rb', line 31 def after_confirmation_path_for(resource_name, resource) return profile_path(resource.nickname) if resource_name == :user_group super end |
#create ⇒ Object
11 12 13 14 15 |
# File 'app/controllers/decidim/devise/confirmations_controller.rb', line 11 def create super do |resource| resource.errors.delete(:decidim_organization_id) if resource.errors.any? end end |
#resource_params ⇒ Object
Since we’re using a single Devise installation for multiple organizations, and user emails can be repeated across organizations, we need to identify the user by both the email and the organization. Setting the organization ID here will be used by Devise internally to find the correct user.
Note that in order for this to work we need to define the ‘confirmation_keys` Devise attribute in the `Decidim::User` model to include the `decidim_organization_id` attribute.
26 27 28 |
# File 'app/controllers/decidim/devise/confirmations_controller.rb', line 26 def resource_params super.merge(decidim_organization_id: current_organization.id) end |