Ejemplo n.º 1
0
        public async Task SyncCurrentUserInfo()
        {
            if (!localStorage.HasAccessToken())
            {
                currentUserProvider.SetUserInfoLoading(false);

                return;
            }

            currentUserProvider.SetUserInfoLoading(true);

            var response = await GetCurrentUserInfo();

            if (response == null)
            {
                var success = await GetRefreshedToken();

                if (success)
                {
                    response = await GetCurrentUserInfo();
                }
            }

            if (response == null)
            {
                currentUserProvider.SetUserInfoLoading(false);

                localStorage.RemoveAuthorizationTokens();
            }
            else
            {
                currentUserProvider.SetCurrentUserInfoFromResponse(response);
            }
        }
        public static void RemoveAuthorizationTokens(this ISyncLocalStorageService localStorage)
        {
            if (localStorage.HasAccessToken())
            {
                localStorage.RemoveItem(LocalStorageConstants.TokenType);
                localStorage.RemoveItem(LocalStorageConstants.AccessToken);
            }

            if (localStorage.HasRefreshToken())
            {
                localStorage.RemoveItem(LocalStorageConstants.RefreshToken);
            }
        }
Ejemplo n.º 3
0
        public static Metadata GetRequestHeaders(ISyncLocalStorageService localStorage)
        {
            Metadata headers = null;

            if (localStorage.HasAccessToken())
            {
                var tokenType   = localStorage.GetTokenType();
                var accessToken = localStorage.GetAccessToken();

                headers = SetAuthorizationHeader(headers, tokenType, accessToken);
            }

            return(headers);
        }