public async Task Logout() { await _localStorage.ClearAsync(); await((ApiAuthenticationStateProvider)_authenticationStateProvider).MarkUserAsLoggedOut(); _httpClient.DefaultRequestHeaders.Authorization = null; }
public async Task Logout() { _httpClient.DefaultRequestHeaders.Authorization = null; await _loclStorageService.ClearAsync(); NotifyAuthenticationStateChanged(Task.FromResult(new AuthenticationState(new ClaimsPrincipal(_unauthorized)))); }
public async Task SignOut() { await localStorage.ClearAsync(); NotifyAuthenticationStateChanged(GetAuthenticationState()); navigation.NavigateTo("/"); }
public async void MarkUserAsLoggedOut() { await _localStorage.ClearAsync(); var anonymousUser = new ClaimsPrincipal(new ClaimsIdentity()); var authState = Task.FromResult(new AuthenticationState(anonymousUser)); NotifyAuthenticationStateChanged(authState); }
internal async Task Logout() { _memberHandler.Logout(); _currentToken = string.Empty; CurrentUser = null; await _localData.ClearAsync(); await _sessionData.ClearAsync(); }
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); }
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; }
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(); } }
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> >()); }
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()); } }
internal async Task ClearCache(ILocalStorageService localStorageService) { await localStorageService.ClearAsync(); }
public async Task Clear() { await _localStorageService.ClearAsync(); }