Class: Decidim::Devise::SessionsController

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

Overview

Custom Devise SessionsController to avoid namespace problems.

Instance Method Summary collapse

Instance Method Details

#after_sign_in_path_for(user) ⇒ Object



9
10
11
12
13
# File 'app/controllers/decidim/devise/sessions_controller.rb', line 9

def (user)
  return  if (user) &&
                                            !user.role?("admin")
  super
end

#after_sign_out_path_for(user) ⇒ Object



27
28
29
# File 'app/controllers/decidim/devise/sessions_controller.rb', line 27

def after_sign_out_path_for(user)
  request.referer || super
end

#first_login_and_not_authorized?(user) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/controllers/decidim/devise/sessions_controller.rb', line 23

def (user)
  user.is_a?(User) && user. == 1 && current_organization.available_authorizations.any?
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.

Returns:

  • (Boolean)


19
20
21
# File 'app/controllers/decidim/devise/sessions_controller.rb', line 19

def pending_redirect?(user)
  store_location_for(user, stored_location_for(user))
end