how to reauthenticate user in Firebase

时间:2018-04-20 21:26:37

标签: android firebase firebase-authentication

hi i need to reauthenticate my users to make the change of user's email and password in firebase. according to the documentation if I am using facebook login and google login I must reauthenticate to make the change.

 private void reauthenticate(){
        String MyEmail = emailText.getText().toString();

        FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
        AuthCredential credential = EmailAuthProvider.getCredential(MyEmail, "Abc123");

        user.reauthenticate(credential)
                .addOnCompleteListener(new OnCompleteListener<Void>() {
                    @Override
                    public void onComplete(@NonNull Task<Void> task) {
                        Log.d(TAG, "User re-authenticated.");

                            updateEmailProfile();
                        } else {
                           Log.d(TAG, "User re-authenticated.");

                        }
                    }
                });

    }

I need a form where I can capture the user's created password, with facebook, google, and email and password.

FirebaseUser user = FirebaseAuth.getInstance (). GetCurrentUser ();

I can only get email name, but not password

1 个答案:

答案 0 :(得分:2)

密码不像电子邮件那样容易访问,因为默认情况下密码是受保护的。如果您想重新对用户进行身份验证,则需要让用户以某种方式重新输入与用户帐户关联的密码。