예제 #1
0
        public async Task <bool> SignIn(UserSignInFormModel form)
        {
            var request = new UserSignInRequest
            {
                Email    = form.Email,
                Password = form.Password
            };

            var response = await signInServiceClient.SignInAsync(request);

            localStorage.SetAuthorizationTokens(response.TokenType, response.AccessToken, response.RefreshToken);

            try
            {
                await currentUserService.SyncCurrentUserInfo();
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                Console.WriteLine(exception.StackTrace);
            }

            return(!response.IsError);
        }
예제 #2
0
        public async Task <bool> GetRefreshedToken()
        {
            if (localStorage.HasRefreshToken())
            {
                var refreshToken = localStorage.GetRefreshToken();

                var requestHeaders = RequestHeadersUtility.GetRequestHeaders(localStorage);

                var response = await userServiceClient.GetRefreshedTokenAsync(new GetRefreshedTokenRequest { RefreshToken = refreshToken }, requestHeaders);

                if (!response.IsError)
                {
                    localStorage.SetAuthorizationTokens(response.TokenType, response.AccessToken, response.RefreshToken);
                }
                else
                {
                    localStorage.RemoveAuthorizationTokens();
                }

                return(!response.IsError);
            }

            return(false);
        }