Is there a way of using "createUserWithEmailAndPassword" ? The reason I'm asking is because I want that the email gets verified before the user can logIn.
firebase.auth().createUserWithEmailAndPassword(mailId, password).then(function(data){
console.log("user created");
firebase.auth().currentUser.sendEmailVerification().then(function() {
console.log("verification email send");
})
}).catch(function(error) {
console.log("error.message");
})
This code signin user automatically and send the verification mail to user. Is there any way to verify email first than signIn.
You can't prevent user with an unverified email address from signing in. That's simply not how Firebase Authentication works: if the user knows the credentials needed to sign in, they've proven who they are and are signed in.
What you can do is prevent them from accessing specific resources, such as the Firebase Database. In fact, my answer to this question shows how to do that (and limit access to users from a specific email domain): How do I lock down Firebase Database to any user from a specific (email) domain?
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