From ef9ff49462c3fdf10d0cdcbb6304715769485835 Mon Sep 17 00:00:00 2001 From: hellekin Date: Fri, 9 Oct 2020 10:31:10 +0200 Subject: Add permissions - `current_agent` is now a full instance of Agent - provide helpers to verify current user roles --- app/controllers/application_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4e71ff8..14f50bf 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -7,8 +7,10 @@ class ApplicationController < ActionController::Base protected + include ApplicationHelper + def current_agent - @current_agent = session[:current_agent] || current_user.presence&.agents&.first&.name || 'IN COMMON' + @current_agent = Agent.find_by(name: session[:current_agent] || current_user.presence&.agents&.first&.name || 'incommon') end helper_method :current_agent -- cgit v1.2.3