Beispiel #1
0
        public async Task <bool> RefreshToken()
        {
            if (_isRefreshingToken)
            {
                return(true);
            }
            else
            {
                _isRefreshingToken = true;
            }

            var store    = DependencyService.Get <ITokenStore> ();
            var newToken = await LoginService.RefreshToken(store.getToken());



            if (newToken != null)
            {
                newToken.mainSiteName = MainSite.name;
                UpdateToken(newToken, store);
                _isRefreshingToken = false;
                return(true);
            }
            else
            {
                _isRefreshingToken = false;
                ShowLogin();
                return(false);
            }
        }
Beispiel #2
0
        public async Task <bool> RefreshToken()
        {
            if (isRefreshingToken)
            {
                return(true);
            }
            else
            {
                isRefreshingToken = true;
            }

            var store     = DependencyService.Get <ITokenStore> ();
            var new_token = await loginService.RefreshToken(store.getToken());

            isRefreshingToken = false;

            if (new_token != null)
            {
                authToken   = new_token;
                currentSite = mainSite;
                webService  = new WebService();

                store.saveToken(new_token);

                MessagingCenter.Send <Xamarin.Forms.Application> (App.Current, "login_succesful");
                MessagingCenter.Send <Xamarin.Forms.Application> (App.Current, "refresh_menu");
                return(true);
            }
            else
            {
                ShowLogin();
                return(false);
            }
        }