Skip to content

Commit 43c8252

Browse files
mattleibowCopilot
andcommitted
Fix Account.razor claim order for workforce tokens
Workforce Entra ID tokens use 'preferred_username' (UPN) instead of the CIAM-specific 'emails' claim. Reorder the fallback chain so preferred_username is checked first, followed by standard 'email' and ClaimTypes.Email. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent dde33d3 commit 43c8252

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

  • 10.0/MauiBlazorWebEntraWorkforce/MauiBlazorWebEntraWorkforce.Shared/Pages

10.0/MauiBlazorWebEntraWorkforce/MauiBlazorWebEntraWorkforce.Shared/Pages/Account.razor

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@
6060

6161
displayName = user.FindFirst("name")?.Value;
6262

63-
email = user.FindFirst("emails")?.Value
63+
// Workforce tokens always include preferred_username (UPN).
64+
// The "email" claim is present when the user has a mail address set.
65+
email = user.FindFirst("preferred_username")?.Value
6466
?? user.FindFirst("email")?.Value
65-
?? user.FindFirst(ClaimTypes.Email)?.Value
66-
?? user.FindFirst("preferred_username")?.Value;
67+
?? user.FindFirst(ClaimTypes.Email)?.Value;
6768
}
6869
}

0 commit comments

Comments
 (0)