cleaned up Website
This commit is contained in:
parent
191572b8bf
commit
796f27aff6
3 changed files with 5 additions and 44 deletions
|
@ -12,10 +12,9 @@
|
|||
|
||||
<main>
|
||||
<div class="top-row px-4">
|
||||
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
|
||||
<AuthorizeView>
|
||||
<Authorized>
|
||||
<a href="#">Hello, @context.User.Identity.Name!</a>
|
||||
<a href="accountedit">Hello, @context.User.Identity.Name!</a>
|
||||
<a href="Account/Logout">Log out</a>
|
||||
</Authorized>
|
||||
<NotAuthorized>
|
||||
|
@ -27,43 +26,5 @@
|
|||
<article class="content px-4">
|
||||
@Body
|
||||
</article>
|
||||
<button @onclick="GetClaimsPrincipalData">Get ClaimsPrincipal Data</button>
|
||||
</main>
|
||||
</div>
|
||||
<p>@_authMessage</p>
|
||||
|
||||
@if (_claims.Count() > 0)
|
||||
{
|
||||
<ul>
|
||||
@foreach (var claim in _claims)
|
||||
{
|
||||
<li>@claim.Type: @claim.Value</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
||||
<p>@_surnameMessage</p>
|
||||
|
||||
@code {
|
||||
private string _authMessage;
|
||||
private string _surnameMessage;
|
||||
private IEnumerable<Claim> _claims = Enumerable.Empty<Claim>();
|
||||
|
||||
private async Task GetClaimsPrincipalData()
|
||||
{
|
||||
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||
var user = authState.User;
|
||||
|
||||
if (user.Identity.IsAuthenticated)
|
||||
{
|
||||
_authMessage = $"{user.Identity.Name} is authenticated.";
|
||||
_claims = user.Claims;
|
||||
_surnameMessage =
|
||||
$"Surname: {user.FindFirst(c => c.Type == ClaimTypes.Surname)?.Value}";
|
||||
}
|
||||
else
|
||||
{
|
||||
_authMessage = "The user is NOT authenticated.";
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue