DEV: Introduce :before_auth DiscourseEvent (#11233)

This is useful for plugins to manipulate the auth hash from OmniAuth before it is read by the Authenticator class
This commit is contained in:
David Taylor
2020-11-13 14:41:54 +00:00
committed by GitHub
parent 0d0ae5e67f
commit dc005c593e
4 changed files with 4 additions and 0 deletions

View File

@ -27,6 +27,7 @@ class Users::AssociateAccountsController < ApplicationController
authenticator = Discourse.enabled_authenticators.find { |a| a.name == provider_name }
raise Discourse::InvalidAccess.new(I18n.t('authenticator_not_found')) if authenticator.nil?
DiscourseEvent.trigger(:before_auth, authenticator, auth)
auth_result = authenticator.after_authenticate(auth, existing_account: current_user)
DiscourseEvent.trigger(:after_auth, authenticator, auth_result)