Class: WcmsApplicationController

Inherits:
ActionController::Base
  • Object
show all
Includes:
Pundit
Defined in:
app/controllers/wcms_application_controller.rb

Overview

ApplicationController should inherit from this controller.

Instance Method Summary collapse

Instance Method Details

#current_userObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/wcms_application_controller.rb', line 17

def current_user
  unless @current_user
    # clear impersonation_id if true_user is not logged in
    if session[:impersonation_id] && !true_user
      session[:impersonation_id] = nil
    end

    # Fetch impersonated user from their ID, otherwise return true_user
    @current_user = (session[:impersonation_id] && User.where(id: session[:impersonation_id]).first) || true_user
  end
  @current_user
end

#true_userObject



12
13
14
# File 'app/controllers/wcms_application_controller.rb', line 12

def true_user
  authentication.user
end