mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Revoke and connect for Yahoo logins
This commit is contained in:
@@ -18,7 +18,23 @@ class Auth::OpenIdAuthenticator < Auth::Authenticator
|
||||
info&.email || ""
|
||||
end
|
||||
|
||||
def after_authenticate(auth_token)
|
||||
def can_revoke?
|
||||
true
|
||||
end
|
||||
|
||||
def revoke(user, skip_remote: false)
|
||||
info = UserOpenId.where("url LIKE ?", "#{@identifier}%").find_by(user_id: user.id)
|
||||
raise Discourse::NotFound if info.nil?
|
||||
|
||||
info.destroy!
|
||||
true
|
||||
end
|
||||
|
||||
def can_connect_existing_user?
|
||||
true
|
||||
end
|
||||
|
||||
def after_authenticate(auth_token, existing_account: nil)
|
||||
result = Auth::Result.new
|
||||
|
||||
data = auth_token[:info]
|
||||
@@ -33,6 +49,11 @@ class Auth::OpenIdAuthenticator < Auth::Authenticator
|
||||
|
||||
user_open_id = UserOpenId.find_by_url(identity_url)
|
||||
|
||||
if existing_account && (user_open_id.nil? || existing_account.id != user_open_id.user_id)
|
||||
user_open_id.destroy! if user_open_id
|
||||
user_open_id = UserOpenId.create!(url: identity_url , user_id: existing_account.id, email: email, active: true)
|
||||
end
|
||||
|
||||
if !user_open_id && @opts[:trusted] && user = User.find_by_email(email)
|
||||
user_open_id = UserOpenId.create(url: identity_url , user_id: user.id, email: email, active: true)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user