From 18954cc7bdd76c906ce1d16da7d1de87a9173ded Mon Sep 17 00:00:00 2001 From: Richard Friberg Date: Thu, 21 Apr 2022 11:06:21 +0200 Subject: [PATCH] Add simple solution to update of oauth with more consistent use of identifiers (#953) --- fastapi_users/manager.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fastapi_users/manager.py b/fastapi_users/manager.py index f464a284..3693ece3 100644 --- a/fastapi_users/manager.py +++ b/fastapi_users/manager.py @@ -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)