aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/welcome_controller.rb
diff options
context:
space:
mode:
authorhellekin <hellekin@cepheide.org>2020-10-06 00:26:44 +0200
committerhellekin <hellekin@cepheide.org>2020-10-06 00:26:44 +0200
commit09ac92747bfbda80a54e44b22576d29d9dfc63c3 (patch)
treef76d590bc8cc979d9a42527afe940c7fe00ff315 /app/controllers/welcome_controller.rb
parentf0a00d02d30509b3b56026e9e4d119bce3a82d99 (diff)
downloadincommon-map-09ac92747bfbda80a54e44b22576d29d9dfc63c3.tar.gz
Extract Role check to a background job
When using SSO, the Discourse sends a list of the user groups. We take the opportunity to update Agency information for the user. This is performed as a background job, as it involves networked requests to the Discourse, e.g., to verify group ownership...
Diffstat (limited to 'app/controllers/welcome_controller.rb')
-rw-r--r--app/controllers/welcome_controller.rb12
1 files changed, 3 insertions, 9 deletions
diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb
index ae24138..0ca7af4 100644
--- a/app/controllers/welcome_controller.rb
+++ b/app/controllers/welcome_controller.rb
@@ -53,16 +53,10 @@ class WelcomeController < ApplicationController
raise
end
# Update user agents
- # TODO: do it as a background job, it has nothing to do here.
- @sso.user_info[:groups].split(',').each do |g|
- a = Agent.find_by_name(g)
- if a
- # TODO: call Discourse and make :leader if group owner
- # TODO: do not create the record if it exists
- a.agencies.create(user: u, roles: 2) # make new user an editor
- Rails.logger.info('User has Agent %s' % g)
- end
+ if @current_user.present?
+ AgencyWatcherJob.perform_later(@current_user, @sso.user_info[:groups].split(','))
end
+ # Save User ID in session
session[:current_user] = @current_user[:external_id]
end