private async Task InitializeOnFirstLaunchAsync() { AuthentificationService.AuthentificationResult result = null; try { result = await this.authentificationService.CheckAuthentificationAsync(); } catch (Exception e) { this.Logger.Error(e, "Exception while tried to verifying authentification."); } if (result != null && result.Succeed) { var currentVersion = this.settingsService.GetValue <string>("Version", null); bool fCurrentVersion = string.Equals(currentVersion, Package.Current.Id.Version.ToVersionString(), StringComparison.OrdinalIgnoreCase); if (fCurrentVersion) { await this.OnViewInitializedAsync(); } else { this.ShowProgressLoadingPopupView(forceToRefreshDb: false); } } else { this.ShowAuthentificationPopupView(); } }
private async void SignIn() { this.BindingModel.IsSigningIn = true; this.BindingModel.ErrorMessage = null; var email = this.BindingModel.Email; var password = this.BindingModel.Password; var rememberPassword = this.BindingModel.RememberAccount; if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) { this.Logger.Warning("Cannot login. Email or password are not provided."); this.BindingModel.ErrorMessage = this.resources.GetString("Authorization_Error_UserNameAndPassword"); } else { var userInfo = new UserInfo(email, password) { RememberAccount = rememberPassword }; this.Logger.Debug("Trying to proceed authentification."); AuthentificationService.AuthentificationResult result = null; try { result = await this.authentificationService.CheckAuthentificationAsync(userInfo); } catch (OperationCanceledException exception) { this.Logger.Debug(exception, "Operation was canceled."); } catch (Exception exception) { this.Logger.Error(exception, "Exception while tried to authentificate."); } if (result != null && result.Succeed) { this.Logger.Debug("Authentification succeded."); if (!rememberPassword) { this.Logger.Debug("User asked to not save user information. Removing user info and password."); this.googleAccountService.ClearUserInfo(); } this.Logger.Debug("Saving user info and password."); this.googleAccountService.SetUserInfo(userInfo); this.View.Close(); } else { if (result != null) { this.Logger.Debug("Authentification is not succeded. {0}.", result.ErrorMessage); this.BindingModel.ErrorMessage = result.ErrorMessage; } else { this.BindingModel.ErrorMessage = this.resources.GetString("Authorization_Error_UnexpectedError"); } } } this.BindingModel.IsSigningIn = false; }