@page "/profile"
@using System.Security.Claims
@inject NavigationManager _navigationManager
Twit Nuke
This is your profile
@claim
@code {
[CascadingParameter]
public Task authenticationState { get; set; }
public Claim claim;
protected override async Task OnInitializedAsync() {
var authState = await authenticationState;
var user = authState.User;
if (user.Identity.IsAuthenticated) {
claim = user.FindFirst(c => c.Type == ClaimTypes.NameIdentifier);
}
else {
_navigationManager.NavigateTo("/");
}
}
}