Пример #1
0
        public void NotifyUserLoggedIn(string token)
        {
            var authenticatedUser = new ClaimsPrincipal(new ClaimsIdentity(JWTParser.ParseClaimsFromJwt(token), "jwtAuthType"));
            var authState         = Task.FromResult(new AuthenticationState(authenticatedUser));

            NotifyAuthenticationStateChanged(authState);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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"))));
        }