title: Node.js username and password authentication
body: <p>I'm currently building a web app using <code>Node.js</code> and <code>Express.js</code>.</p>
  
  <p>I'm looking for a way to have a simple server-side authentication with a username and password in my main <code>app.js</code> file which is listening for a <code>post</code> request at <code>http://www.domain.com/login</code>:</p>
  
  <p><strong>app.js</strong></p>
  
  <pre><code>app.post('/login', function(req, res) {
    // some server-side code for a username and password
  }
  </code></pre>
  
  <p>On the client-side I have a simple login form with a username and password. This form is going to posted to the server:</p>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;form method="post" action="/login"&gt;
  &lt;input type="text" id="user" name="user" /&gt;
  &lt;input type="password" id="pass" name="pass" /&gt;
  &lt;button type="submit"&gt;Login&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I am looking to achieve this <strong>without</strong> the use of any <code>ExpressJS</code> plugins.</p>
  
  <p><strong>Edit:</strong> So my question is, how do I achieve a simple username and password authentication in ExpressJS and NodeJS?</p>