aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/application_controller.rb
blob: 4e71ff8d4d2998f7c7daf2c2d3d539c12f369d9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class ApplicationController < ActionController::Base
  protect_from_forgery with: :null_session

  require 'sso'

  before_action :current_user

  protected

  def current_agent
    @current_agent = session[:current_agent] || current_user.presence&.agents&.first&.name || 'IN COMMON'
  end
  helper_method :current_agent

  def current_user
    @current_user ||= User.find_by(external_id: session[:current_user]) if session[:current_user].present?
  end
  helper_method :current_user
end