aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/application_controller.rb
blob: 1eff1a9fc4387ff8129a8dc5a60d0b41c43305bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

class ApplicationController < ActionController::Base
  require 'sso'

  before_action :current_user

  protected

  include ApplicationHelper
  include AgentsHelper

  # Set current agent globally
  def current_agent
    @current_agent = Agent.find_by(name: current_agent_name)
  end
  helper_method :current_agent

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

end