How to send the reset password email link using the firebase in react

using this we can send the email link to reset the password from the firebase email will be sent.

From the docs, to send the email: https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#sendpasswordresetemail

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

const auth = getAuth();
sendPasswordResetEmail(auth, email)
  .then(() => {
    // Password reset email sent!
    // ..
  })
  .catch((error) => {
    const errorCode = error.code;
    const errorMessage = error.message;
    // ..
  });

Once the user clicks the link in the email, they will end up on your site’s email landing page (defined in the Auth email templates or through your custom third party email solution). The link will have a parameter “oobCode”, which is needed to reset the password.

On that landing page, ask the user for a new password, and then pass the oobCode and the new password to the confirmPasswordReset function: https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#confirmpasswordreset

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

const auth = getAuth();
const oobCode = [However Angular reads querystring values]('oobCode');
confirmPasswordReset (auth, oobCode)
  .then(() => {
    // Password has been reset!
    // ..
  })
  .catch((error) => {
    const errorCode = error.code;
    const errorMessage = error.message;
    // ..
  });

Leave a comment

Your email address will not be published. Required fields are marked *