Пример #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 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"))));
        }