0
votes

I have account admin and another account want to reset password, with process like this,

User A reset password > send email to admin > admin reset password > admin send new password to user A (with email)> user A login with new password from Admin.. Can I do like this, tell me example source code java. Thanks

resetPass.setOnClickListener(view -> {
    String userMail = resetEmail.getText().toString();
    if (TextUtils.isEmpty(userMail)) {
        Toast.makeText(ForgotPassActivity.this, "Please write your valid address first", Toast.LENGTH_SHORT).show();
    } 
    else {
        auth.sendPasswordResetEmail(userMail).addOnCompleteListener(new OnCompleteListener<Void>() {
            @Override
            public void onComplete(@NonNull Task<Void> task) {
                if (task.isSuccessful()) {
                    Toast.makeText(ForgotPassActivity.this, "Please check your email account", Toast.LENGTH_SHORT).show();

                    startActivity(new Intent(ForgotPassActivity.this, Log_inActivity.class));
                } else {
                    Toast.makeText(ForgotPassActivity.this, "Email not found, please try again.", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
});
1

1 Answers

0
votes

Firebase Authentication only allows sending a password reset email to the currently signed in user. You can't send a password reset email to another user, as that would open the system up to abuse.

To implement the flow you describe, you'll need to implement your own email sending, and password reset. You can use the Firebase Admin SDK to handle the Firebase aspects of it (get the user, update password), but will need to find another system to send email, and implement your own verification code.