Ejemplo n.º 1
0
        public string GetPass()
        {
            Context        mContext = Android.App.Application.Context;
            AppPreferences ap       = new AppPreferences(mContext);

            return(ap.GetAccessPass());
        }
Ejemplo n.º 2
0
        public bool GetSharedPreferences()
        {
            Context        mContext = Android.App.Application.Context;
            AppPreferences ap       = new AppPreferences(mContext);

            return(ap.GetAccessKey());
        }
Ejemplo n.º 3
0
        public async Task <bool> LogOut()
        {
            Context        mContext = Android.App.Application.Context;
            AppPreferences ap       = new AppPreferences(mContext);

            ap.SaveAccessKey(false);
            ap.SaveAccessPass("");
            ap.SaveAccessEmail("");
            FirebaseAuth.Instance.SignOut();
            return(true);
        }
Ejemplo n.º 4
0
        public async Task <bool> AuthenticateUser(string email, string password)
        {
            try
            {
                await FirebaseAuth.Instance.SignInWithEmailAndPasswordAsync(email, password);

                //shared preferences
                Context        mContext = Android.App.Application.Context;
                AppPreferences ap       = new AppPreferences(mContext);
                ap.SaveAccessKey(true);
                ap.SaveAccessEmail(email);
                ap.SaveAccessPass(password);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
        public async Task <bool> RegisterUser(string email, string password)
        {
            try
            {
                await Firebase.Auth.FirebaseAuth.Instance.CreateUserWithEmailAndPasswordAsync(email, password);

                var profileUpdates = new Firebase.Auth.UserProfileChangeRequest.Builder();
                profileUpdates.SetDisplayName(email);
                var build = profileUpdates.Build();
                var user  = FirebaseAuth.Instance.CurrentUser;
                await user.UpdateProfileAsync(build);

                //shared preferences
                Context        mContext = Android.App.Application.Context;
                AppPreferences ap       = new AppPreferences(mContext);
                ap.SaveAccessKey(true);
                ap.SaveAccessEmail(email);
                ap.SaveAccessPass(password);

                return(true);
            }
            catch (FirebaseAuthWeakPasswordException ex)
            {
                throw new Exception(ex.Message);
            }
            catch (FirebaseAuthInvalidCredentialsException ex)
            {
                throw new Exception(ex.Message);
            }
            catch (FirebaseAuthUserCollisionException ex)
            {
                throw new Exception(ex.Message);
            }
            catch (Exception)
            {
                throw new Exception("An unknown error occurred, please try again.");
            }
        }