Module: EnforcesAdminAuthentication

Extended by:
ActiveSupport::Concern
Included in:
Admin::ApplicationController, Admin::Clusters::ApplicationsController, Admin::ClustersController
Defined in:
app/controllers/concerns/enforces_admin_authentication.rb

Overview

EnforcesAdminAuthentication

Controller concern to enforce that users are authenticated as admins

Upon inclusion, adds `authenticate_admin!` as a before_action

Instance Method Summary collapse

Instance Method Details

#authenticate_admin!Object


16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/concerns/enforces_admin_authentication.rb', line 16

def authenticate_admin!
  return render_404 unless current_user.admin?
  return unless Feature.enabled?(:user_mode_in_session)

  unless current_user_mode.admin_mode?
    current_user_mode.request_admin_mode!
    store_location_for(:redirect, request.fullpath) if storable_location?
    redirect_to(new_admin_session_path, notice: _('Re-authentication required'))
  end
end

#storable_location?Boolean

Returns:

  • (Boolean)

27
28
29
# File 'app/controllers/concerns/enforces_admin_authentication.rb', line 27

def storable_location?
  request.path != new_admin_session_path
end