public async Task <bool> TrySilentLogin() { try { var credentials = await StorageVault.GetCredentials(); return(await LoginWithEmailPassword(credentials.Item1, credentials.Item2)); } catch (Exception) { return(false); } }
public bool SignOut() { try { _auth.SignOut(); StorageVault.ClearCredentials(); return(true); } catch (Exception) { return(false); } }
public async Task <bool> UpdatePassword(string newPassword) { try { await _auth.UpdatePassword(newPassword); var currentCredentials = await StorageVault.GetCredentials(); await StorageVault.SetCredentials(currentCredentials.Item1, newPassword); return(true); } catch (WeakPasswordException) { throw; } catch (Exception) { return(false); } }
public async Task <bool> CreateUserWithEmailPassword(string email, string password) { try { string token = await _auth.CreateUserWithEmailPassword(email, password); if (!string.IsNullOrEmpty(token)) { await StorageVault.SetCredentials(email, password); await StorageVault.SetToken(token); await UserProfileService.Instance.LoadUserProfile(email); return(true); } return(false); } catch (Exception) { throw; } }
public async Task <bool> LoginWithEmailPassword(string email, string password) { try { string token = await _auth.LoginWithEmailPassword(email, password); if (!string.IsNullOrEmpty(token)) { try { await StorageVault.SetCredentials(email, password); await StorageVault.SetToken(token); await UserProfileService.Instance.LoadUserProfile(email); } catch (Exception) { Debug.WriteLine("Either can't save credentials or load profile"); } return(true); } else { return(false); } } catch (InvalidLoginException) { return(false); } catch (Exception) { throw; } }