public void NotifyUserLoggedIn(string token) { var authenticatedUser = new ClaimsPrincipal(new ClaimsIdentity(JWTParser.ParseClaimsFromJwt(token), "jwtAuthType")); var authState = Task.FromResult(new AuthenticationState(authenticatedUser)); NotifyAuthenticationStateChanged(authState); }
public Task Handle(IdentityAuthorizationSuccessEvent @event, CancellationToken token) { var jwtInfo = JWTParser.Parser(@event.AccessToken); var userInfoJson = jwtInfo.Payload; var user = User.Current; user.Name = "test"; return(Task.CompletedTask); }
public override async Task <AuthenticationState> GetAuthenticationStateAsync() { var token = await _localStorage.GetItemAsync <string>(SD.Local_Token); if (token == null) { return(new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity()))); } _httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", token); return(new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity(JWTParser.ParseClaimsFromJwt(token), "jwtAuthType")))); }