Reputation: 159
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!');
});
Upvotes: 3
Views: 1956
Reputation: 11
.then((userData)=>{
firebase.auth().currentUser.sendEmailVerification()
this worked for me
Upvotes: 0
Reputation: 465
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);
});
Upvotes: 5
Reputation: 159
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);
});
Upvotes: 8