When new user creates his signIn automatically in firebase in javascript

Is there a way to use "createUserWithEmailAndPassword"? The reason I am asking is because I want the email to be validated before the user can log in.

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 automatically enters the user and sends the mail to the user. Is there a way to check email first than signIn.

+3


source to share


1 answer


You cannot prevent a user from entering an unverified email address. This is simply not how Firebase Authentication works: if the user knows the credentials required to log in, they have proven who they are and that they are logged in.



What you can do is prevent them from accessing certain resources like Firebase database. In fact, my answer to this question shows how to do this (and restrict access to users from a specific email domain): How to lock a Firebase database to any user from a specific (email)

+1


source







All Articles