Firebase Reset Password Link (Did not receive) using firebase react native
import { sendPasswordResetEmail } from '@firebase/auth'
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
const onForgot = async (email) => {
const auth = firebase.auth();
await sendPasswordResetEmail(auth, email)
.then(() => {
alert("reset email sent to " email);
})
.catch(function (e) {
console.log(e);
});
}
please help, and thanks in advance.
CodePudding user response:
I am not sure how it works in react native. But in reactjs, the way we instantiate the auth is different from what I'm seeing here. We do something like this:
import Firebase from "../../Firebase/Firebase";
var auth = getAuth(Firebase);
//some code here e.g. your main function etc
sendPasswordResetEmail(auth, user.email)
.then(() => {
message.success("Password reset email sent!")
})
.catch((error) => {
message.error("Unable to send reset password link :: " error.message)
});
Just verify whether you are indeed getting your "auth" instantiated in the right way here. A simple import doesn't cut it.
EDIT: My code is using version 9 of firebase. Please check with the version you are using and make sure your auth is being instantiated right according to the version
EDIT 2: Remember to enable firebase auth "email sign in" in the firebase console authentication section
All the best.
CodePudding user response:
If you're not getting an error back from the call to sendPasswordResetEmail
, there is likely nothing wrong with your code. More likely the message was sent, but got stuck in a spam filter or spam box. So check your spam folder to see if the message showed up there.