private async Task InternalLoginAsync(string email, string pwd)
        {
            var authOptions         = new FirebaseAuthOptions(Secrets.FIREBASE_API_KEY);
            var firebaseAuthService = new FirebaseAuthService(authOptions);

            var request = new VerifyPasswordRequest()
            {
                Email    = email,
                Password = pwd
            };

            try
            {
                VerifyPasswordResponse response = await firebaseAuthService.VerifyPassword(request);

                _currentUser = new User
                {
                    Email = response.Email,
                    Token = response.IdToken
                };
            }
            catch (FirebaseAuthException e)
            {
                _telemetry.LogError("Error in firebase login", e);
            }
        }
        public static VerifyPasswordResponse Unmarshall(UnmarshallerContext context)
        {
            VerifyPasswordResponse verifyPasswordResponse = new VerifyPasswordResponse();

            verifyPasswordResponse.HttpResponse = context.HttpResponse;
            verifyPasswordResponse.RequestId    = context.StringValue("VerifyPassword.RequestId");

            return(verifyPasswordResponse);
        }
Esempio n. 3
0
        private async void login_Click(object sender, EventArgs e)
        {
            if (email_text.Text.Count() > 0 && password_text.Text.Count() > 0)
            {
                VerifyPasswordRequest request = new VerifyPasswordRequest();
                request.Email    = email_text.Text;
                request.Password = password_text.Text;
                try
                {
                    VerifyPasswordResponse response = await fService.VerifyPassword(request);

                    if (remember_me_check.Checked)
                    {
                        Settings.Default["email"]    = email_text.Text;
                        Settings.Default["password"] = password_text.Text;
                        Settings.Default.Save();
                    }

                    String uid = response.LocalId;

                    FirebaseResponse user_record = await client.GetAsync("users/" + uid);

                    UserData data = user_record.ResultAs <UserData>();

                    if (data.role == UserData.ROLE_ORGANIZER || data.role == UserData.ROLE_ADMIN)
                    {
                        DeliveryApp deliveryApp = new DeliveryApp();
                        deliveryApp.ShowDialog();
                    }
                    else if (data.role == UserData.ROLE_FULFILLMENT)
                    {
                        FulFillmentStuffForm target = new FulFillmentStuffForm();
                        target.Show();
                        Close();
                    }
                }
                catch (FirebaseAuthException ex)
                {
                    String msg = ex.Message;
                    if (remember_me_check.Checked)
                    {
                        /*Settings.Default["email"] = "";
                         * Settings.Default["password"] = "";
                         * Settings.Default.Save();*/
                    }
                    MessageBox.Show("Email address or password may not correct.");
                }
                catch (Exception ex) {
                    MessageBox.Show("Network status may not good, Try again later.");
                    Close();
                }
            }
        }