Reputation: 2602
I need this to return from AuthenticationStateProvider
in blazor web assembly when user is null.
public override async Task<AuthenticationState> GetAuthenticationStateAsync()
{
var principal = new ClaimsPrincipal();
var user = await _userService.FetchUserFromBrowser();
if (user is not null)
{
var authenticatedUser = await _userService.SendAuthenticateRequestAsync(user.Username, user.Password);
if (authenticatedUser is not null)
{
principal = authenticatedUser.ToClaimsPrincipal();
CurrentUser = authenticatedUser;
}
}
else
{
/*TODO*/
}
return new(principal);
}
Upvotes: 0
Views: 135
Reputation: 8811
var principal = new ClaimsPrincipal(new GenericIdentity("anonymous"));
Upvotes: 0