Need help with sending email verification upon user sign up. Here is the code in provider/user.ts:
onCreate(form: NgForm) {
var user = new User();
user.name = form.value.name;
user.email = form.value.email;
user.contact = form.value.contact;
if(form.value.gender == "male") {
user.gender = "male";
} else {
user.gender = "female"
}
let loading = this.mProv.getLoader('Creating your account...', 0);
loading.present();
this.afAuth.auth.createUserWithEmailAndPassword(form.value.email, form.value.password)
.then( res=> {
let user = firebase.auth().currentUser;
user.sendEmailVerification();
})
.then(data => {
user.id = data.uid;
this.userProvider.addUser(user)
.then(_ =>
loading.dismiss()
)
.catch(error => {
loading.dismiss();
this.mProv.showAlertOkMessage('Error','Sign up error. Please try again later.');
});
})
.catch(error => {
loading.dismiss();
this.mProv.showAlertOkMessage('Error','Sign up error. Please try again later.');
});
}
Struggling to find the right place to put user.sendEmailVerification, as data.uid shows red underline when placed within:
.then( res=> {
let user = firebase.auth().currentUser;
user.sendEmailVerification();
})
Your assistance would be greatly appreciated.