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!'); }); }
Comments
Post a Comment