Beispiel #1
0
        public static void RedirectToLogin(UIViewController viewController, LoadingOverlay loadingOverlay)
        {
            PreferenceHandler.setLoggedIn(false);
            PreferenceHandler.SetToken(string.Empty);
            var LoginViewController = (LoginViewController)viewController.Storyboard.InstantiateViewController("LoginViewController");

            viewController.NavigationController.PushViewController(LoginViewController, false);
        }
Beispiel #2
0
        public static void ShowMessage(string message, LoadingOverlay loadingOverlay, UIViewController viewController)
        {
            if (loadingOverlay != null)
            {
                loadingOverlay.Hide();
            }
            UIAlertController alertController = UIAlertController.Create("Message", message, UIAlertControllerStyle.Alert);

            alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, (action) => Console.WriteLine("OK Clicked.")));
            viewController.PresentViewController(alertController, true, null);
        }
Beispiel #3
0
        public static async Task RefreshToken(UIViewController viewController, LoadingOverlay loadingOverlay)
        {
            string tokenURL = string.Format(B2CConfig.RefreshTokenURL, B2CConfig.Tenant, B2CPolicy.SignInPolicyId, B2CConfig.ClientId, PreferenceHandler.GetRefreshToken());
            var    response = await InvokeApi.Authenticate(tokenURL, string.Empty, HttpMethod.Post);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                string strContent = await response.Content.ReadAsStringAsync();

                var tokenNew = JsonConvert.DeserializeObject <AccessToken>(strContent);
                PreferenceHandler.SetToken(tokenNew.id_token);
                PreferenceHandler.SetRefreshToken(tokenNew.refresh_token);
            }
            else if (response.StatusCode == System.Net.HttpStatusCode.BadRequest || response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
            {
                RedirectToLogin(viewController, loadingOverlay);
            }
        }