Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Commit

Permalink
Fix #15 User.Identity.Name was always null
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-szabo committed Jul 15, 2018
1 parent a9a7fea commit f0ff3b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public async Task<IActionResult> Index(string email)
if (User.Identity.IsAuthenticated)
{
// Get users's email.
email = email ?? User.Identity.Name ?? User.FindFirst("preferred_username").Value;
email = email ?? User.FindFirst("preferred_username")?.Value;
ViewData["Email"] = email;

// Get user's id for token cache.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public void Configure(string name, OpenIdConnectOptions options)

options.TokenValidationParameters = new TokenValidationParameters
{
// Ensure that User.Identity.Name is set correctly after login
NameClaimType = "name",

// Instead of using the default validation (validating against a single issuer value, as we do in line of business apps),
// we inject our own multitenant validation logic
ValidateIssuer = false,
Expand Down

0 comments on commit f0ff3b6

Please sign in to comment.