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



22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/decidim/devise/sessions_controller.rb', line 22

def (user)
  if user.present? && user.blocked?
    check_user_block_status(user)
  elsif user.needs_password_update?
    change_password_path
  elsif (user) && !user.admin? && !pending_redirect?(user)
    decidim_verifications.
  else
    super
  end
end

#after_sign_out_path_for(user) ⇒ Object



46
47
48
# File 'app/controllers/decidim/devise/sessions_controller.rb', line 46

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

#destroyObject

rubocop: enable Rails/LexicallyScopedActionFilter



13
14
15
16
17
18
19
20
# File 'app/controllers/decidim/devise/sessions_controller.rb', line 13

def destroy
  current_user.invalidate_all_sessions!
  if params[:translation_suffix].present?
    super { set_flash_message! :notice, params[:translation_suffix], { scope: "decidim.devise.sessions" } }
  else
    super
  end
end

#first_login_and_not_authorized?(user) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/controllers/decidim/devise/sessions_controller.rb', line 42

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

Returns:

  • (Boolean)


38
39
40
# File 'app/controllers/decidim/devise/sessions_controller.rb', line 38

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