I'm basically having an issue where the user can sign in without verifying their email address (clicking the link sent to their email). My code currently looks like this & every time I enter "isEmailVerified()" it tells me that no such function exists.
const fbuilds = [];
const frooms = [];
clearErrors();
fire.auth().createUserWithEmailAndPassword(email, password)
.then((userCredential) => {
userCredential.user.sendEmailVerification();
alert('Please follow the link sent to your email address to verify your account.')
fire.auth().signOut();
})
.catch((err) => {
switch (err.code){
case "auth/email-already-in-use":
case "auth/invalid-email":
setEmailError(err.message);
break;
case "auth/weak-password":
setPasswordError(err.message);
break;
}
});
and my auth listener function looks like this:
fire.auth().onAuthStateChanged((user) => {
if(user){
if (user.isEmailVerified()){ //user.emailVerified
clearInputs();
setUser(user);
}
} else {
setUser("");
}
});
};
The error message is correct. There is no method called "isEmailVerified" on the User object. A look at that API documentation suggests that there is a property called emailVerified that you can check.
if (user.emailVerified) { ... }
Please remember to use code samples and documentation for JavaScript and not other languages like Java that might have different APIs.