Пример #1
0
        public async Task <AuthResponse> LoginWithoutSaveToLocalStorage(AuthRequest user)
        {
            var jsonContent = new StringContent(JsonConvert.SerializeObject(user), Encoding.UTF8, "application/json");
            var response    = await _httpClient.PostAsync($"{Constants.API_URL}authenticate", jsonContent);

            var authResponse = new AuthResponse();

            if (response.IsSuccessStatusCode)
            {
                authResponse = await DeserializeToAuthResponse(response);

                IsLoggedIn = true;
            }

            return(authResponse);
        }
Пример #2
0
 private async Task SaveUsernameInLocalStorage(AuthResponse authResponse)
 {
     await _localStorage.SetItemAsync("username", SaveUsernameInLocalStorage(authResponse.Username));
 }
Пример #3
0
 private async Task SaveTokenInLocalStorage(AuthResponse authResponse)
 {
     await _localStorage.SetItemAsync("authToken", SaveTokenInLocalStorage(authResponse.Token));
 }