コード例 #1
0
        public async Task Logout()
        {
            await _localStorage.ClearAsync();

            await((ApiAuthenticationStateProvider)_authenticationStateProvider).MarkUserAsLoggedOut();
            _httpClient.DefaultRequestHeaders.Authorization = null;
        }
コード例 #2
0
        public async Task Logout()
        {
            _httpClient.DefaultRequestHeaders.Authorization = null;
            await _loclStorageService.ClearAsync();

            NotifyAuthenticationStateChanged(Task.FromResult(new AuthenticationState(new ClaimsPrincipal(_unauthorized))));
        }
コード例 #3
0
        public async Task SignOut()
        {
            await localStorage.ClearAsync();

            NotifyAuthenticationStateChanged(GetAuthenticationState());
            navigation.NavigateTo("/");
        }
コード例 #4
0
        public async void MarkUserAsLoggedOut()
        {
            await _localStorage.ClearAsync();

            var anonymousUser = new ClaimsPrincipal(new ClaimsIdentity());
            var authState     = Task.FromResult(new AuthenticationState(anonymousUser));

            NotifyAuthenticationStateChanged(authState);
        }
コード例 #5
0
ファイル: AppState.cs プロジェクト: fahidul01/IIT-MobileApp
        internal async Task Logout()
        {
            _memberHandler.Logout();
            _currentToken = string.Empty;
            CurrentUser   = null;
            await _localData.ClearAsync();

            await _sessionData.ClearAsync();
        }
コード例 #6
0
        public async Task MarkUserAsLoggedOut()
        {
            var anonymousUser = new ClaimsPrincipal(new ClaimsIdentity());
            var authState     = Task.FromResult(new AuthenticationState(anonymousUser));
            await _localStorage.ClearAsync();

            _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", string.Empty);
            NotifyAuthenticationStateChanged(authState);
        }
コード例 #7
0
        public async Task Logout()
        {
            //await _localStorage.RemoveItemAsync("authToken");
            //await _localStorage.RemoveItemAsync("CurrentUserId");
            //await _localStorage.RemoveItemAsync("CurrentUser");
            await _localStorage.ClearAsync();

            ((ApiAuthenticationStateProvider)_authenticationStateProvider).MarkUserAsLoggedOut();
            _httpClient.DefaultRequestHeaders.Authorization = null;
        }
コード例 #8
0
ファイル: TokenService.cs プロジェクト: leonibr/hero-app-wasm
        public async Task StoreToken(LocalUserInfo localUserInfo)
        {
            try
            {
                await storageService.SetItemAsync(Constants.UserKey, localUserInfo);
            }
            catch (Exception ex)
            {
                DebugPrint.Log("StoreToken");
                DebugPrint.Log(ex.Message);

                await storageService.ClearAsync();
            }
        }
コード例 #9
0
        public async Task <DbResponse <User> > Check(int userId)
        {
            var result = await _http.PostAsJsonAsync("api/auth/check", userId);

            if (result.StatusCode == System.Net.HttpStatusCode.Unauthorized)
            {
                IsLoggedIn       = false;
                UserService.user = null;
                await _localStorage.ClearAsync();

                _nav.NavigateTo("/", forceLoad: true);
            }

            return(await result.Content.ReadFromJsonAsync <DbResponse <User> >());
        }
コード例 #10
0
        private async Task <ClaimsPrincipal> GetPrincipal()
        {
            var version = await localStorage.GetItemAsync <string>("version");

            var correctVersion = configuration.GetSection("Version").Value;

            if (version != correctVersion)
            {
                await localStorage.ClearAsync();

                await localStorage.SetItemAsync(nameof(version), correctVersion);
            }
            try
            {
                var telegramUserInfo = await localStorage.GetItemAsync <TelegramUserInfo>("telegramUserInfo");

                if (telegramUserInfo == null)
                {
                    Console.WriteLine("no user info");
                    return(new ClaimsPrincipal());
                }
                else
                {
                    var(success, claims) = await TryGetInternalClaims(telegramUserInfo);

                    if (success)
                    {
                        var tgIdentity       = TelegramWidgetClaimsIdentityGenerator.GetIdentityForUserInfo(telegramUserInfo);
                        var internalIdentity = new ClaimsIdentity(claims, InternalClaimConstants.IDENTITY_AUTH_TYPE);

                        return(new ClaimsPrincipal(new ClaimsIdentity[] { tgIdentity, internalIdentity }));
                    }
                    else
                    {
                        Console.WriteLine("can't login");

                        return(new ClaimsPrincipal());
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("exception");
                Console.WriteLine(ex);
                return(new ClaimsPrincipal());
            }
        }
コード例 #11
0
 internal async Task ClearCache(ILocalStorageService localStorageService)
 {
     await localStorageService.ClearAsync();
 }
コード例 #12
0
 public async Task Clear()
 {
     await _localStorageService.ClearAsync();
 }