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

View File

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