mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
FIX: when associating Github account disassociate others
There are some cases where an email floats from one GitHub account to another if this happens just take over the Github mapping record
This commit is contained in:
@ -86,7 +86,12 @@ class Auth::GithubAuthenticator < Auth::Authenticator
|
||||
if !!candidate[:verified] && (user = User.find_by_email(candidate[:email]))
|
||||
result.email = candidate[:email]
|
||||
result.email_valid = !!candidate[:verified]
|
||||
GithubUserInfo.create(
|
||||
|
||||
GithubUserInfo
|
||||
.where('user_id = ? OR github_user_id = ?', user.id, github_user_id)
|
||||
.destroy_all
|
||||
|
||||
GithubUserInfo.create!(
|
||||
user_id: user.id,
|
||||
screen_name: screen_name,
|
||||
github_user_id: github_user_id
|
||||
|
Reference in New Issue
Block a user