title: firebase.auth().signInWithPhoneNumber + express on Node.js
body: <p>I've got a trouble when trying to implement backend firebase Authorization.
  After I had read carefully the docs (<a href="https://firebase.google.com/docs/auth/web/phone-auth" rel="nofollow noreferrer">https://firebase.google.com/docs/auth/web/phone-auth</a>), I figured out that Authorization need to be proceded by two steps: </p>
  
  <ol>
  <li>send phone</li>
  <li>send code</li>
  </ol>
  
  <p>I divided Google's example on two promises, but can't understand how to store current user and  whether or not I've done everything in an appropriate way.</p>
  
  <pre><code>  app.post("/appSignInByPhone", (req, res) =&gt; {
          let {phoneNumber, applicationVerifier} = req.body;
          firebase.auth().signInWithPhoneNumber(phoneNumber, applicationVerifier)
              .then(() =&gt; res.end("Waiting for code"))
              .catch(
                  error =&gt; res.json(error)
              );
  });
  
  app.post("/appSignInPhoneVerify", (req, res) =&gt; {
          let {verificationCode} = req.body;
              firebase.auth.ConfirmationResult.confirm(verificationCode)
              .then( user =&gt; res.json(user))
              .catch(
                  error =&gt; res.json(error)
              );
  });
  </code></pre>
  
  <p>Maybe there are some ways of merging these to request to one...</p>