Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

when new user create it signIn automatically in firebase in javascript

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.

like image 560
Ashish kumar singh Avatar asked Dec 20 '25 16:12

Ashish kumar singh


1 Answers

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?

like image 119
Frank van Puffelen Avatar answered Dec 22 '25 07:12

Frank van Puffelen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!