In React Login component Firebase login signup is working but when I am trying to send a reset password Link then it is not working. there is no getting email value from the field, but sign-in is working. So unable to send the reset password link in my email.
Login Submit Button : it's working:
const handleToSubmit = (event) => { event.preventDefault(); const email = event.target.email.value; const password = event.target.password.value; signInWithEmailAndPassword(email, password) }
Reset password Function code: it's not working:
<!-- language: lang-js -->
const resetPassword = async (event) => {
const email = event.target.email.value
if (email) {
await sendPasswordResetEmail(email);
toast.success(`Check your Email ⮞ ${email}`);
} else {
toast.warn('Enter Email ☹ ');
}
}
<!-- end snippet -->
My Email input field: it's working for login but not for reset password
<Form.Group controlId="formBasicEmail">
<Form.Control type="email" name="email" placeholder="Enter email" />
</Form.Group>
Reset Click Button: it's not working:
<button onClick={resetPassword}> Reset Password </button>
I think you are using firebase v9.
So you should pass auth
as parameter to the function:
import { getAuth, sendPasswordResetEmail } from "firebase/auth";
const auth = getAuth();
sendPasswordResetEmail(auth, email)
.then(() => {
// Password reset email sent!
// show the toast
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.