diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/jobs/ensure_agent_job.rb | 5 |
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 |