From b5739232a535f89b48b54ee52ea7d9bb59f8a46f Mon Sep 17 00:00:00 2001 From: hellekin Date: Tue, 2 Feb 2021 23:13:58 +0100 Subject: Introduce an Anonymous Agent Since we moved away from Roles it's important to maintain a default Agent that is distinct from the previous default IN COMMON Agent. Previously, a user without a proper group would be granted the `observer` role in the default Agent, enough to create new resources. Now, we consider anonymous users to be part of the Anonymous Agent, which also brings the possibility for them to edit yet to be accepted Resources. --- app/controllers/application_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5299f54..1eff1a9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -10,14 +10,18 @@ class ApplicationController < ActionController::Base protected include ApplicationHelper + include AgentsHelper + # Set current agent globally def current_agent - @current_agent = Agent.find_by(name: session[:current_agent] || current_user.presence&.agents&.first&.name || 'incommon') + @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 -- cgit v1.2.3