Populate email on login for users with empty email field
When a user already exists in the DB, get_or_create_from_azure was returning early without updating their email from Azure AD claims. Users created before email sync was in place would permanently show empty emails in User Management. Now syncs email from Azure AD claims on each login if the stored email is empty. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d7fd435210
commit
c6f7b0d5f1
1 changed files with 4 additions and 0 deletions
|
|
@ -42,6 +42,10 @@ class UserRepository:
|
|||
"""Get existing user or create new one from Azure AD claims."""
|
||||
user = await self.get_by_azure_oid(azure_ad_oid)
|
||||
if user:
|
||||
# Sync email from Azure AD if not yet stored
|
||||
if not user.email and email:
|
||||
user.email = email
|
||||
await self.session.flush()
|
||||
return user
|
||||
|
||||
# Create new user
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue