How to know whether the Register Email is verified or not in Firebase?
You can use firebase.auth().currentUser.emailVerified
This will return true
or false
.
According to the documentation, the User
object contains an emailVerified
property.
So the user to which the signInWithEmailAndPassword
method's promise resolves - or the user that is passed to the onAuthStateChanged
method's callback - can be inspected and the value of emailVerified
can be checked.
- If you are already loggedIn below solutions can help you to check email verified status.
1) The recommended way to get the current user is by setting an observer on the Auth object:
firebase.auth().onAuthStateChanged(authUser => {
if(authUser.user.emailVerified){ //This will return true or false
console.log('email is verified')
}else{
console.log('email not verified')
}
})
2) You can also get the currently signed-in user by using the currentUser property.
var user = firebase.auth().currentUser;
if (user.emailVerified) {
// email is verified.
} else {
// email is not verified.
}
- If you are not loggedIn then please try below solution.
firebase.auth().signInWithEmailAndPassword(email, password ).then(authUser => {
if(authUser.user.emailVerified){ //This will return true or false
console.log('email is verified')
}else{
console.log('email not verified')
}
}).catch(function(error) {
});
you can add an attribute at firebase database for the state of your user verification link