private async void SignInBtn_Click(object sender, RoutedEventArgs e) { MessageTB.Text = ""; Loader.Visibility = Visibility.Visible; var user = UserNameTB.Text; var password = PasswordTB.Password; try { User signedInUser = await UserConnection.AuthenticateUser(new User() { Username = user, Password = password }); SignedIn?.Invoke(this, new SignedInEventArgs() { User = signedInUser }); ApplicationRuntimeData.AuthUser = new WebApi.Models.AuthUser() { Username = user, Password = password }; ApplicationRuntimeData.CurrentUser = signedInUser; } catch (Exception ex) { MessageTB.Text = ex.Message; } Loader.Visibility = Visibility.Hidden; }
// Called when a sign-in with profile data completes. // void handleSignInWithSignInResult(Task<Firebase.Auth.SignInResult> task) // { // Debug.Log($"[handleSignInWithSignInResult]"); // SignedOut?.Invoke(task.Result.User); // } // Called when a sign-in without fetching profile data completes. void handleSignInWithUser(Task <FirebaseUser> task) { switch (task.Status) { case TaskStatus.Faulted: Debug.LogWarning($"[EmailAuth::handleSignInWithUser] Task faulted: {task.Exception.ToString()}"); handleFault(task.Exception); break; case TaskStatus.RanToCompletion: this.User = task.Result; Debug.Log($"[EmailAuth] Sign in complete {this.User.UserId}"); SignedIn?.Invoke(task.Result); break; default: Debug.LogWarning($"[EmailAuth::handleSignInWithUser] Unhandled task status: {task.Status}"); break; } }
internal async Task SignInAsync() { try { IsBusy = true; _hud.Show(LoginMessage); var credentials = new Credentials(UserName, Password); Result validationResult = await _credentialValidator.ValidateAsync(credentials) .ConfigureAwait(false); if (!validationResult.IsSuccessful) { _alerts.ShowError(validationResult.ErrorMessage); return; } var saveResult = await _credentialStorage.SaveCredentialsAsync(credentials) .ConfigureAwait(false); if (!saveResult.IsSuccessful) { _alerts.ShowError(saveResult.ErrorMessage); return; } _backgroundSync.Enable(); SignedIn?.Invoke(this, EventArgs.Empty); } finally { _hud.Dismiss(); IsBusy = false; } }
protected void OnSignedIn() { SignedIn?.Invoke(this, null); }
public void InvokeSignedIn(string email) { SignedIn?.Invoke(email); }