From fc6e7dd3f1e62d07e4f96f96a0535af9ca4579d3 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 24 May 2021 17:35:51 +0100 Subject: [PATCH] DEV: Add `session` to `before_auth` and `after_auth` hooks (#13123) This allows plugins to store/modify things in the session (e.g. the destination_url). This change is backwards compatible with existing plugins. If they do not specify a third argument, they will just be passed the first two. --- app/controllers/users/omniauth_callbacks_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 2b702962c38..7f17c3890c4 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -33,10 +33,10 @@ class Users::OmniauthCallbacksController < ApplicationController Discourse.redis.setex "#{Users::AssociateAccountsController::REDIS_PREFIX}_#{current_user.id}_#{token}", 10.minutes, auth.to_json return redirect_to "#{Discourse.base_path}/associate/#{token}" else - DiscourseEvent.trigger(:before_auth, authenticator, auth) + DiscourseEvent.trigger(:before_auth, authenticator, auth, session) @auth_result = authenticator.after_authenticate(auth) @auth_result.user = nil if @auth_result&.user&.staged # Treat staged users the same as unregistered users - DiscourseEvent.trigger(:after_auth, authenticator, @auth_result) + DiscourseEvent.trigger(:after_auth, authenticator, @auth_result, session) end preferred_origin = request.env['omniauth.origin']