Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Firebase sendPasswordResetEmail doesn't send email

I have a problem concerning my application using firebase: If I want to enable the users to reset their password themselves firebase doesn’t send an email to their address. If I do it myself from the firebase console it works fine. I’m trying it like this:

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

Has someone some insights for me, why this isn’t working? I get my auth like this:

this.firebaseApp = initializeApp(environment.firebaseConfig);
this.auth = getAuth(firebaseApp);

I am using the Firebase Modular SDK (V9.0.0+).

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I would be really grateful if someone can help me!
Cheers!

>Solution :

Where are you getting environment from? If you are getting it correctly and environment.firebaseConfig is not undefined then this should work.

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

const app = initializeApp(environment.firebaseConfig);
const auth = getAuth();
sendPasswordResetEmail(auth, email)
  .then(() => {
    // Password reset email sent!
  })
  .catch((error) => {
    const errorCode = error.code;
    const errorMessage = error.message;
  });
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading