Beispiel #1
0
        public async Task <bool> TrySilentLogin()
        {
            try
            {
                var credentials = await StorageVault.GetCredentials();

                return(await LoginWithEmailPassword(credentials.Item1, credentials.Item2));
            }
            catch (Exception)
            {
                return(false);
            }
        }
Beispiel #2
0
 public bool SignOut()
 {
     try
     {
         _auth.SignOut();
         StorageVault.ClearCredentials();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
        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;
            }
        }
Beispiel #5
0
        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;
            }
        }