aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
authorhellekin <hellekin@cepheide.org>2021-02-02 23:13:58 +0100
committerhellekin <hellekin@cepheide.org>2021-02-02 23:13:58 +0100
commitb5739232a535f89b48b54ee52ea7d9bb59f8a46f (patch)
tree189ce7ebf48371b29def0fddc7c2e41e7cfa38bd /app/controllers/application_controller.rb
parent8e404c4f3cf7880681b6f4cdf3c378e084ad54d2 (diff)
downloadincommon-map-b5739232a535f89b48b54ee52ea7d9bb59f8a46f.tar.gz
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.
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb6
1 files changed, 5 insertions, 1 deletions
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