Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Trigger Discourse events from authenticators. (#7724)

Dan Ungureanua046f6ced5d6
diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb
index d7fda5e304d..d7473a51f6e 100644
--- a/app/controllers/users/omniauth_callbacks_controller.rb
+++ b/app/controllers/users/omniauth_callbacks_controller.rb
@@ -43,6 +43,7 @@ class Users::OmniauthCallbacksController < ApplicationController
else
@auth_result = authenticator.after_authenticate(auth)
end
+ DiscourseEvent.trigger(:after_auth, authenticator, @auth_result)
preferred_origin = request.env['omniauth.origin']
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 76ed63f2812..3b1ba66f8e9 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1165,6 +1165,7 @@ class UsersController < ApplicationController
# We're likely going to contact the remote auth provider, so hijack request
hijack do
+ DiscourseEvent.trigger(:before_auth_revoke, authenticator, user)
result = authenticator.revoke(user, skip_remote: skip_remote)
if result
render json: success_json
diff --git a/lib/auth/result.rb b/lib/auth/result.rb
index fc939408f27..8ad478c2921 100644
--- a/lib/auth/result.rb
+++ b/lib/auth/result.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class Auth::Result
- attr_accessor :user, :name, :username, :email, :user,
+ attr_accessor :user, :name, :username, :email,
:email_valid, :extra_data, :awaiting_activation,
:awaiting_approval, :authenticated, :authenticator_name,
:requires_invite, :not_allowed_from_ip_address,