У меня есть функция, которая позволяет пользователю регистрироваться или создавать учетную запись. Он также отправляет подтверждение после регистрации. Я хочу, чтобы пользователи, чья электронная почта была проверена для входа в систему. Что мне делать?
Это моя функция входа в систему.
function signIn() {
var email = $("#emailtxt").val();
var password = $("#passwordtxt").val();
var auth = firebase.auth();
firebase.auth().signInWithEmailAndPassword(email,
password).then(function(value) {
//NEED TO 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);
});
}
Я надеюсь, что вы можете console.log текущего пользователя
var user = firebase.auth().currentUser;
console.log(user); //there you can see emailVerified boolean object will be available.
if(user.emailVerified){
// then you can allow your users to be logged in your site.
}
else if(!user.emailVerified){ //send a emailverification mail to the user
firebase.auth().currentUser.sendEmailVerification().then(function() {
alert('Email Verification Sent!');
});
}