My skills with firebase is basic, what i want to get is, only the users who have the verified mail will be able to enter the app, if not show the error of the email that has not been verified. here my code:
login (){
const user = firebase.auth().currentUser;
const emailVerified = user.emailVerified;
const validate = this.refs.formId.getValue();
if (validate && emailVerified != 'false') {
firebase.auth().signInWithEmailAndPassword(validate.email, validate.password)
.then(() => {
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
if (errorCode === 'auth/wrong-password') {
Toast.show({ text: 'Wrong password!', position: 'bottom', buttonText: 'Try Again' })
if (emailVerified === 'false') {
Toast.show({ text: 'Email Not Verified!', position: 'bottom', buttonText: 'Try Again' })
}else{
Toast.show({ text: 'Something Wrong!', position: 'bottom', buttonText: 'Try Again' })
}
});
}
}
I get this error: null is not an object (evaluating 'user.emailVerified)