FIX: Allow OAuth2Authenticator to handle existing associations (#15259)

OAuth2Authenticator is considered deprecated, and isn't used in core. However, some plugins still depend on it, and this was breaking the signup of previously-staged users. There is no easy way to make an end-end test of this in core, but I will be adding an integration test in the SAML plugin.
This commit is contained in:
David Taylor 2021-12-10 19:53:14 +00:00 committed by GitHub
parent b93b6c4299
commit e42f33b6ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,13 +45,10 @@ class Auth::OAuth2Authenticator < Auth::Authenticator
def after_create_account(user, auth)
data = auth[:extra_data]
Oauth2UserInfo.create(
uid: data[:uid],
provider: data[:provider],
name: auth[:name],
email: auth[:email],
user_id: user.id
)
association = Oauth2UserInfo.find_or_initialize_by(provider: data[:provider], uid: data[:uid])
association.user = user
association.email = auth[:email]
association.save!
end
def description_for_user(user)