I am trying to make firebase create user by email and send the verification email.
It has changed I believe in version 5+
I cannot seem to get it to function.
Can someone help explain where am I going wrong?
The following error message I keep getting is
TypeError: user.sendEmailVerification is not a function
This is my TS file.
onSubmit(form: NgForm) {
const fullname = form.value.fullname;
const email = form.value.email;
const password = form.value.password;
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(function(user) {
user.sendEmailVerification();
})
.then(function () {
console.log('User signup success');
alert('Signed Up');
})
.catch(function (err) {
console.log(err);
alert('Error!');
});
In the end, I found this solution.
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(userData => {
userData.user.sendEmailVerification();
console.log(userData);
})
.catch(err => {
console.log(err);
});
In Firebase 9 there is separate method
import { sendEmailVerification } from "firebase/auth";
Example:
sendEmailVerification(auth.currentUser)
.then(() => {
// Your code is here
})
.catch((error) => {
console.log('Email verification error', error);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With