Add simple solution to update of oauth with more consistent use of identifiers (#953)

This commit is contained in:
Richard Friberg
2022-04-21 11:06:21 +02:00
committed by GitHub
parent 6ba70bdbc6
commit 18954cc7bd

View File

@@ -209,7 +209,11 @@ class BaseUserManager(Generic[models.UC, models.UD]):
# Update oauth
updated_oauth_accounts = []
for existing_oauth_account in user.oauth_accounts: # type: ignore
if existing_oauth_account.account_id == oauth_account.account_id:
if (
existing_oauth_account.account_id == oauth_account.account_id
and existing_oauth_account.oauth_name == oauth_account.oauth_name
):
oauth_account.id = existing_oauth_account.id
updated_oauth_accounts.append(oauth_account)
else:
updated_oauth_accounts.append(existing_oauth_account)