From d631419750908c5b96aa30c410abcc897a8dd2a6 Mon Sep 17 00:00:00 2001 From: IN COMMON Collective Date: Mon, 22 Mar 2021 21:21:27 +0100 Subject: [FIX] Ensure User agents are up to date --- app/jobs/ensure_agent_job.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app/jobs') diff --git a/app/jobs/ensure_agent_job.rb b/app/jobs/ensure_agent_job.rb index 127cf1d..a37b6fa 100644 --- a/app/jobs/ensure_agent_job.rb +++ b/app/jobs/ensure_agent_job.rb @@ -11,9 +11,12 @@ class EnsureAgentJob < ApplicationJob # Ensure the logged in user has a current agent # In order to do this, we first check the existing agents against the user's # groups. If none match, we assign the user to the default Anonymous agent. - existing_agents = Agent.find_by(name: groups) + existing_agents = Agent.where(name: groups) if existing_agents.nil? user.agents << default_agent unless user.agents.include? default_agent + else + # Update user agents + user.agents << existing_agents - user.agents end end end -- cgit v1.2.3