Search code examples
firebasefirebase-authenticationangularfire2

How to know whether the Register Email is verified or not in Firebase?


onSubmit(formData) {
if(formData.valid) {
  console.log(formData.value);
  this.af.auth.createUser({
    email: formData.value.email,
    password: formData.value.password
  }).then(
    authState => {
    authState.auth.sendEmailVerification();
    this.router.navigate(['/login'])
  }).catch(
    (err) => {
    console.log(err);
    this.error = err;
  })
}
}

In Firebase, I set the SendEmailVerfication like the code above, and the email could send normally.However, in my app, there is no difference between the user who does not click the verification email with those clicked, how to make a difference?


Solution

  • 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.