Home > front end >  Reactjs firebase reset password without sending reset password email
Reactjs firebase reset password without sending reset password email

Time:05-02

I am using firebase authentication for my admin website. I know how to reset the password sending the reset password email. I am using that method in my client website. But I want my admin user to reset the password without sending the reset password since they already login. Just like using new password and confirm password form and submit to reset and login again. I don't want my admin user to send the reset password email.

May I know how to reset the firebase authentication without sending the reset password email?

CodePudding user response:

You can use the updatePassword method that comes with firebase.

import { getAuth, updatePassword } from "firebase/auth";

const auth = getAuth();

const user = auth.currentUser;
const newPassword = getPWFromForm();

updatePassword(user, newPassword).then(() => {
  // Update successful.
}).catch((error) => {
  // An error ocurred
  // ...
});

You would create a textfield where the user enters their new password and then passes it to the updatePassword function.

CodePudding user response:

With the code in RyanY's answer you can update the password of the current user.

If you want to change the password of another user, you will need to use the Admin SDK in a trusted environment, such as your development machine, a server you control, or Cloud Functions/Cloud Run. With that SDK, you can update any properties of any user (including their password) by their UID.

  • Related