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

pyy picture pyy · Apr 1, 2017 · Viewed 11.2k times · Source
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?

Answer

cartant picture cartant · Apr 2, 2017

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.