title: How to check if Firebase user's email is verified before signing in to React web app
body: <p>I have a React web app which has Firebase Auth built in.</p>
  <p>Upon a User signing in, I only want the request to successfully complete if the User's email is verified. If it isn't, I want it to error out.</p>
  <p>I suspect this will be done through accessing this (taken from the Firebase docs):</p>
  <pre><code>var user = firebase.auth().currentUser;
  var name, email, photoUrl, uid, emailVerified;
  
  if (user != null) {
    name = user.displayName;
    email = user.email;
    photoUrl = user.photoURL;
    emailVerified = user.emailVerified;
    uid = user.uid;  // The user's ID, unique to the Firebase project. Do NOT use
                     // this value to authenticate with your backend server, if
                     // you have one. Use User.getToken() instead.
  }
  </code></pre>
  <p>However, I'm unsure if I can implement this in my sign-in flow, so the user doesn't get redirected to their dashboard, before the check is then done. I want it to happen upon submitting the request on the sign in page.</p>
  <p>Can someone state how I can tweak this function to build in a check to see if the email is verified, before the user is signed in?</p>
  <pre><code>  onSubmit = (e) =&gt; {
  
      e.preventDefault()
  
      firebase.auth().signInWithEmailAndPassword(this.state.email, this.state.password)
        .then(function(response) {
          console.log(response);
          console.log(&quot;Successfully logged in.&quot;)
        })
        .catch(function(error) {
          var errorCode = error.code;
          var errorMessage = error.message;
          console.log(errorCode);
          console.log(errorMessage);
        });
  
        this.props.history.push(&quot;/dashboard&quot;)
  
    }
  </code></pre>
  <p>Or is it only possible to check once the user is signed in? Any help would be appreciated!</p>