public void NotifyUserAuthentication(string token) { var authenticatedUser = new ClaimsPrincipal(new ClaimsIdentity(JwtParser.ParseClaimsFromJwt(token), "jwtAuthType")); var authenticationState = Task.FromResult(new AuthenticationState(authenticatedUser)); NotifyAuthenticationStateChanged(authenticationState); }
public override async Task <AuthenticationState> GetAuthenticationStateAsync() { var token = await _localStorage.GetItemAsync <string>("authToken"); if (string.IsNullOrWhiteSpace(token)) { return(_anonymous); } _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", token); return(new AuthenticationState( new ClaimsPrincipal(new ClaimsIdentity(JwtParser.ParseClaimsFromJwt(token), "jwtAuthType")))); }