Verify hashed password in NodeJS
<p>I've started learning NodeJS since a few weeks. I'm building my first application where users can register a account and login with their credentials. When a user registers a account the password will be hashed. I'm using password-hash from NPM. The hashing of the password works fine. The problem is verifying the password when a user logs in. This is my code:</p>

<p><strong>Registration:</strong></p>

<pre><code>router.post('/register', function(req, res, next) {
    req.getConnection(function (err, connection) {
        var data = {
            username: req.body.username,
            password: passwordHash.generate(req.body.password),
            mail: req.body.mail,
            hometown: req.body.hometown
        };
        connection.query("INSERT INTO users set ? ", [data], function(err, results) {
            res.redirect('/secret/login');
        });
    });
});
</code></pre>

<p><strong>Logging in and verifying hashed password:</strong></p>

<pre><code>router.post('/login', function(req, res, next) {

   var user_login = req.body.username;
   var password_login = req.body.password;

    req.getConnection(function(err, connection) {

        if (err) throw err;

        connection.query('SELECT * FROM users WHERE username = ?', [user_login], function(err, results) {

            if(results[0] &amp;&amp; passwordHash.verify(password_login, results[0].password)) {

                  req.session.regenerate(function(){
                  req.session.login = true;
                  req.session.username = user_login;
                  req.session.data = results[0];
                  res.redirect(req.baseUrl);

            });

            } else {

                console.log(results[0]); // true
                res.redirect(req.baseUrl);

            }

        });

      });

    });
</code></pre>

<p>I've also tried </p>

<pre><code>console.log(passwordHash.verify(password_login, results[0].password));
</code></pre>

<p>When I sign in with the username &amp; password from one of the registred accounts, the boolean response in the console.log is 'false' every time.
I couldn't find a answer on the internet so thats why I'm asking it here. I hope someone can help me solve this! </p>

<p><strong>I'm using these modules:</strong></p>

<pre><code>"ejs": "^2.3.4",
"express": "^4.13.3",
"express-myconnection": "^1.0.4",
"multer": "^1.1.0",
"mysql": "^2.9.0",
"password-hash": "^1.2.2"
</code></pre>

<p>What am I doing wrong when verifying the hashed password? </p>