/// <summary> /// Attempts to log the user in /// </summary> /// <param name="parameter"></param> /// <returns>SecureString passed in from the view</returns> public async Task LoginAsync(IHavePassword parameter) { await RunCommandAsync(() => this.LoginIsRunning, async() => { // Call the database LoginResultDataModel result = await IoC.ClientDataStore.CheckLoginAsync(new LoginCredentialsDataModel { Email = Email, Password = parameter.SecurePassword.Unsecure(), }); // if the response has an error -> display it if (result == null) { // done await IoC.UI.ShowMessageBoxDialog(new DialogMessageBoxViewModel { Message = "Login Failed" }, "Login failed!"); return; } // if we got here -> successfully logged in IoC.ApplicationViewModel.MasterHash = Crypt.Hash(parameter.SecurePassword.Unsecure()); // let the application view model what happens on the successful login IoC.ApplicationViewModel.HandleSuccessfulLogin(result); }); }
public void HandleLogout() { RunningLoginInfo = null; MasterHash = string.Empty; GoToPage(ApplicationPage.Login); }
/// <summary> /// Handles what happens on a successful login /// </summary> public void HandleSuccessfulLogin(LoginResultDataModel loginResult) { RunningLoginInfo = loginResult; GoToPage(ApplicationPage.MainPage); }