diff --git a/apps/wizarr-backend/wizarr_backend/helpers/emby.py b/apps/wizarr-backend/wizarr_backend/helpers/emby.py index a58c8be5..93ba5f40 100644 --- a/apps/wizarr-backend/wizarr_backend/helpers/emby.py +++ b/apps/wizarr-backend/wizarr_backend/helpers/emby.py @@ -376,6 +376,14 @@ def sync_emby_users(server_api_key: Optional[str] = None, server_url: Optional[s create_user(username=emby_user["Name"], token=emby_user["Id"], email=email) info(f"User {emby_user['Name']} successfully imported to database.") + # If the user does exist then update their username and email + else: + user = get_user_by_token(emby_user["Id"], verify=False) + user.username = emby_user["Name"] + user.email = emby_user["ConnectUserName"] if "ConnectUserName" in emby_user else None + user.save() + info(f"User {emby_user['Name']} successfully updated in database.") + # If database_users.token not in emby_users.id, delete from database for database_user in database_users: if str(database_user.token) not in [str(emby_user["Id"]) for emby_user in emby_users]: diff --git a/apps/wizarr-backend/wizarr_backend/helpers/jellyfin.py b/apps/wizarr-backend/wizarr_backend/helpers/jellyfin.py index 34ff5949..09c21113 100644 --- a/apps/wizarr-backend/wizarr_backend/helpers/jellyfin.py +++ b/apps/wizarr-backend/wizarr_backend/helpers/jellyfin.py @@ -376,6 +376,13 @@ def sync_jellyfin_users(server_api_key: Optional[str] = None, server_url: Option create_user(username=jellyfin_user["Name"], token=jellyfin_user["Id"]) info(f"User {jellyfin_user['Name']} successfully imported to database.") + # If the user does exist then update their username + else: + user = get_user_by_token(jellyfin_user["Id"], verify=False) + user.username = jellyfin_user["Name"] + user.save() + info(f"User {jellyfin_user['Name']} successfully updated in database.") + # If database_users.token not in jellyfin_users.id, delete from database for database_user in database_users: if str(database_user.token) not in [str(jellyfin_user["Id"]) for jellyfin_user in jellyfin_users]: