title: Firebase Authentication Server Side
body: <p>I am trying to learn how to make a simple authentication application. If I have this in my app.js file, </p>
  
  <pre class="lang-js prettyprint-override"><code>var logIn = function(req, res) {
    const email = req.body.email;
    const password = req.body.password;
    firebase.auth().signInWithEmailAndPassword(email, password).then(function() {
      const user = firebase.auth().currentUser;
      const emailVerified = user.emailVerified;
      console.log("Email verified status: " + emailVerified);
   });
  };
  </code></pre>
  
  <pre class="lang-js prettyprint-override"><code>var doSomething(req, res) {
    var user = firebase.auth().currentUser;
    // do something with the variable user
  }
  </code></pre>
  
  <p>this is not ok, right? Because when multiple users log in, the <code>currentUser</code> would just be assigned to the last person who logged in. (Please correct me if that is not true.)</p>
  
  <p>So, I found these:</p>
  
  <p><a href="https://stackoverflow.com/questions/46626585/how-to-authenticate-a-firebase-user-from-server-without-client-side-auth/46632696">How to authenticate a firebase user from server without client side auth?</a></p>
  
  <p><a href="https://firebase.google.com/docs/auth/web/auth-state-persistence" rel="nofollow noreferrer">https://firebase.google.com/docs/auth/web/auth-state-persistence</a></p>
  
  <p>They suggested doing something like this: </p>
  
  <pre class="lang-js prettyprint-override"><code>firebase.auth().setPersistence(firebase.auth.Auth.Persistence.NONE)
  .then(function() {
    return firebase.auth().signInWithRedirect(provider);
  });
  </code></pre>
  
  <p>Does this mean, that adding <code>setPersistence = None</code> allows us to use <code>firebase.auth().currentUser</code> on the server-side, AKA in app.js, even when multiple users are logged in?</p>
  
  <p>Can we just declare <code>firebase.auth().setPersistence(firebase.auth.Auth.Persistence.NONE)</code> once in the app.js file or do we need to use promise for each function?</p>
  
  <p>I recently started learning JS and using Firebase. Sorry if some questions are silly. Thanks so much for your help.</p>