aboutsummaryrefslogtreecommitdiff
path: root/app/jobs
diff options
context:
space:
mode:
authorIN COMMON Collective <collective@incommon.cc>2021-03-22 21:21:27 +0100
committerIN COMMON Collective <collective@incommon.cc>2021-03-22 21:21:27 +0100
commitd631419750908c5b96aa30c410abcc897a8dd2a6 (patch)
tree2aee1fbd3b97c64736b7970eadd4b4377395695f /app/jobs
parent3fd2284c91231a142139b794cbb0a151b6adf8d0 (diff)
downloadincommon-map-d631419750908c5b96aa30c410abcc897a8dd2a6.tar.gz
[FIX] Ensure User agents are up to date
Diffstat (limited to 'app/jobs')
-rw-r--r--app/jobs/ensure_agent_job.rb5
1 files changed, 4 insertions, 1 deletions
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