Ejemplo n.º 1
0
        public static async Task <bool> CheckAuthTokenExpiration()
        {
            if (string.IsNullOrEmpty(Core.Settings.AuthToken))
            {
                return(false);
            }
            if (Core.Settings.AuthTokenExpiredAt > DateTime.UtcNow && (Core.Settings.AuthTokenExpiredAt - DateTime.UtcNow).TotalMinutes > 15)
            {
                return(true);
            }
            var res = await PGService.RefreshAuthToken(Core.Settings.AuthToken);

            if (!res.Item1)
            {
                return(false);
            }

            Core.Settings.AuthToken          = res.Item2;
            Core.Settings.AuthTokenExpiredAt = res.Item3;

            var ssoData = await PGService.GetSSOData();

            if (ssoData == null)
            {
                return(false);
            }
            Core.Settings.SsoData = ssoData;

            //Task.Run(() => HPHService.SetDeviceInfo());
            return(true);
        }
Ejemplo n.º 2
0
        public async void LoginCallback(string callbackUrl)
        {
            try
            {
                BtnLogin.IsEnabled       = false;
                BtnLogin.BackgroundColor = Color.LightGray;
            }
            catch (Exception ex) {
            }

            while (_loginCallbackProcess)
            {
                await Task.Delay(200);
            }

            (App.Current.MainPage as ContainerPage)?.ShowActivityIndicator();

            _loginCallbackProcess = true;
            try
            {
                if (string.IsNullOrWhiteSpace(callbackUrl) || _authTokenReceived)
                {
                    return;
                }

                var res = await PGService.GetNewAuthToken(callbackUrl);

                if (res.Item1)
                {
                    _authTokenReceived               = true;
                    Core.Settings.AuthToken          = res.Item2;
                    Core.Settings.AuthTokenExpiredAt = res.Item3;
                    var ssoData = await PGService.GetSSOData();

                    if (ssoData == null)
                    {
                        LoginFailed();
                        return;
                    }
                    Core.Settings.SsoData = ssoData;
                    LoginFinish();
                }
                else
                {
                    LoginFailed();
                }
            }
            finally
            {
                _loginCallbackProcess = false;
            }
        }