Skip to content Skip to sidebar Skip to footer

Preventing "email Not Found" Error From Firebase When Calling Send Password Reset Email Method

I'm using Firebase Authentication and the Javascript client library for my web app to allow users to log in and out. I've implemented a 'Forgot Password' form to allow a user to re

Solution 1:

Big thanks to @Alchemist Shahed who pointed me to the fetchSignInMethodsForEmail method, which returns an array of signin methods for a given email. If the array is empty, then they have not signed in yet. I modified my above code to look like the following:

handleSubmit = event => {
    event.preventDefault();
    firebase.auth().fetchSignInMethodsForEmail(this.state.email)
    .then(result => {
      if (result.length > 0) {
        firebase.auth().sendPasswordResetEmail(this.state.email).catch((error) => {
          console.log("Error Sending Email", error);
        });
      }
    .catch((error) => {
      console.log("Error Reaching Firebase: ", error);
    });
  };

As an aside, the Admin SDK apparently doesn't have a sendPasswordResetEmail method. However, if your preference is to call the sendPasswordResetEmail from an API, you can use both the Javascript SDK and Node.js SDK together on a server as described in this answer.

Post a Comment for "Preventing "email Not Found" Error From Firebase When Calling Send Password Reset Email Method"