Class: Decidim::Devise::SessionsController
- Inherits:
-
Devise::SessionsController
- Object
- Devise::SessionsController
- Decidim::Devise::SessionsController
- Includes:
- Decidim::DeviseControllers
- Defined in:
- app/controllers/decidim/devise/sessions_controller.rb
Overview
Custom Devise SessionsController to avoid namespace problems.
Instance Method Summary collapse
- #after_sign_in_path_for(user) ⇒ Object
- #after_sign_out_path_for(user) ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #first_login_and_not_authorized?(user) ⇒ Boolean
-
#pending_redirect?(user) ⇒ Boolean
Calling the ‘stored_location_for` method removes the key, so in order to check if there’s any pending redirect after login I need to call this method and use the value to set a pending redirect.
Instance Method Details
#after_sign_in_path_for(user) ⇒ Object
20 21 22 23 24 25 26 |
# File 'app/controllers/decidim/devise/sessions_controller.rb', line 20 def after_sign_in_path_for(user) if (user) && !user.admin? && !pending_redirect?(user) decidim_verifications. else super end end |
#after_sign_out_path_for(user) ⇒ Object
40 41 42 |
# File 'app/controllers/decidim/devise/sessions_controller.rb', line 40 def after_sign_out_path_for(user) request.referer || super end |
#create ⇒ Object
11 12 13 |
# File 'app/controllers/decidim/devise/sessions_controller.rb', line 11 def create super end |
#destroy ⇒ Object
15 16 17 18 |
# File 'app/controllers/decidim/devise/sessions_controller.rb', line 15 def destroy current_user.invalidate_all_sessions! super end |
#first_login_and_not_authorized?(user) ⇒ Boolean
36 37 38 |
# File 'app/controllers/decidim/devise/sessions_controller.rb', line 36 def (user) user.is_a?(User) && user.sign_in_count == 1 && current_organization..any? && user.verifiable? end |
#pending_redirect?(user) ⇒ Boolean
Calling the ‘stored_location_for` method removes the key, so in order to check if there’s any pending redirect after login I need to call this method and use the value to set a pending redirect. This is the only way to do this without checking the session directly.
32 33 34 |
# File 'app/controllers/decidim/devise/sessions_controller.rb', line 32 def pending_redirect?(user) store_location_for(user, stored_location_for(user)) end |