javascript - How to to logged in users that has verified email only -


this question has answer here:

i have function enable user sign or create account. sends verification after signing up. want users email verified logged in.what do?

this login function.

   function signin() {    var email = $("#emailtxt").val();    var password = $("#passwordtxt").val();    var auth = firebase.auth();             firebase.auth().signinwithemailandpassword(email,     password).then(function(value) {       //need pull user data?                             var user = firebase.auth().currentuser;       if(user){         console.log(user.uid);         $("#popup").click();       }     }).catch(function(error) {    // handle errors here.    var errorcode = error.code;    var errormessage = error.message;    if (errorcode === 'auth/wrong-password') {      alert('wrong password.');    } else {     alert(errormessage);   }   console.log(error); });      } 

i hope can console.log current user

var user = firebase.auth().currentuser; console.log(user); //there can see emailverified boolean object available. if(user.emailverified){    // can allow users logged in site.  } else if(!user.emailverified){ //send emailverification mail user   firebase.auth().currentuser.sendemailverification().then(function() {     alert('email verification sent!');   });  } 

added picture of user mail verified or not


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -