Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to get user's attributes from Identity in Blazor Server with organization authentication

$
0
0

In the template provided for authentication you see an email address displayed in the LoginDisplay component, which is what the Name property of ...Identity, as shown below:

<AuthorizeView><Authorized>        Hello, @context.User.Identity.Name!<a href="AzureAD/Account/SignOut">Log out</a></Authorized><NotAuthorized><a href="AzureAD/Account/SignIn">Log in</a></NotAuthorized></AuthorizeView>

What I would like to know is how to access other information about an authenticated user. Like a full name, for example, in a simple way. I've found that with Linq you can get data from the Claims property like so:

@context.User.Claims.Where(c => c.Type == "name").FirstOrDefault().Value.ToString()

Is that how we should get that information, or is there a better/preferred way to access that data from an authenticated user?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>