title: Firebase Auth - User not logged in after Firebase sign up and redirect
body: <p>I am creating an account for a user with firebase.  After the account is created, I redirect to the home page, which checks if I am logged in.  Oddly enough, I am not logged in.  </p>
  
  <p><strong>On Create Account Page:</strong></p>
  
  <pre><code>createAccount() {
    firebaseAuth().createUserWithEmailAndPassword(this.state.email, this.state.password).then((user) =&gt; {
      // write some data to database
      firebase.database().ref().child('users').child(user.uid).child('someKey').set(this.state.email).then(function() {
        // send email verification
        user.sendEmailVerification().then(function() {
          console.log("sent email verification");
          // Go to home page
          this.props.history.push('/home');
        }.bind(this)).catch(function(error) {
          console.log("Error: account created but no verification email sent.");
        }.bind(this));
      }.bind(this)).catch((error) =&gt; {
        console.log('Error: while writing to database');
      });
    // catch any error while creating user
    }).catch((error) =&gt; {
      console.log('Error: while creating account');
    });
  }
  </code></pre>
  
  <p><strong>On Home Page:</strong></p>
  
  <pre><code>componentDidMount() {
    firebase.auth().onAuthStateChanged(function (user) {
      if (!user) {
        console.log("no user logged in");  
        this.props.history.replace('/login'); // ISSUE: Always redirected to login, even after signup and login
        return
      } else {
        console.log("Woo! User is logged in!");
      }
    }.bind(this))
  }
  </code></pre>
  
  <p>Alternative attempts:</p>
  
  <ul>
  <li>I have tried explicitly logging the user in after signup, but the same result occurs</li>
  <li>replaced <code>this.createAccount</code> with <code>() =&gt; this.createAccount</code> for <code>onClick</code> handler (same result)</li>
  <li>used <code>firebase.auth()</code> instead of <code>firebaseAuth()</code> (same result)</li>
  </ul>
  
  <p><strong>Does anyone understand why I am not logged in?</strong></p>
  
  <p>** <strong>EDIT:</strong> **</p>
  
  <p>Below is how I am initializing my app:</p>
  
  <pre><code>&lt;!-- Firebase --&gt;
  &lt;script src="https://www.gstatic.com/firebasejs/4.0.0/firebase.js"&gt;&lt;/script&gt;
  &lt;script&gt;
    // Initialize Firebase
    var config = {
      apiKey: "XXXXXXXXX",
      authDomain: "myproject.firebaseapp.com",
      databaseURL: "https://myproject.firebaseio.com",
      projectId: "XXXXXXXXX",
      storageBucket: "XXXXXXXXX.appspot.com",
      messagingSenderId: "XXXXXXXXX"
    };
    firebase.initializeApp(config);
  &lt;/script&gt;
  </code></pre>
  
  <p>It may be worth noting: If I sign in with an account that was not just created (or if I wait a while and then sign in to the account I created), there doesn't seem to be an issue with retaining the authorization when redirected.  It seems to be that it's only when I create a new user and then redirect that it loses the logged in user.</p>