private async void OnSendTokenClicked(object obj) { if (SecureStorageHelper.CheckIfUserSessionIsActive().Result) { App.Current.MainPage = new NavigationPage(new ItemsPage()); } if (string.IsNullOrEmpty(Token)) { MessagingCenter.Send(this, "AuthError", "Token cannot be empty."); return; } IsBusy = true; ApiTwoFactorResponse apiResponse = await _apiService.TwoFactorLogIn(await SecureStorageHelper.GetUserId(), Token); IsBusy = false; if (apiResponse.VerificationStatus != 1) { if (apiResponse.VerificationStatus == 0) { MessagingCenter.Send(this, "AuthError", apiResponse.Messages.First()); return; } else { MessagingCenter.Send(this, "AuthError", "Your code has expired. Try log in again."); SecureStorageHelper.ClearData(); await App.Current.MainPage.Navigation.PopModalAsync(); return; } } IsBusy = true; if (!_jwtHelper.ValidateToken(apiResponse.AccessToken, out _)) { // indicate errors MessagingCenter.Send(this, "AuthError", "Json web token is invalid"); await App.Current.MainPage.Navigation.PopModalAsync(); return; } await SecureStorageHelper.SaveUserData(apiResponse); //App.Current.MainPage.Navigation.InsertPageBefore(new ItemsPage(), TwoFactorPage); // await Navigation.PopAsync(); await App.Current.MainPage.Navigation.PopModalAsync(); IsBusy = false; App.Current.MainPage = new NavigationPage(new ItemsPage()); }
void Handle_Clicked(object sender, System.EventArgs e) { SecureStorageHelper.ClearData(); App.Current.MainPage = new NavigationPage(new LoginPage()); }