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

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

diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb
index d7fda5e..d7473a5 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 76ed63f..3b1ba66 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 fc93940..8ad478c 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,

GitHub sha: a046f6ce

1 Like