Compare passwords BcryptJS
<p>So I'm trying to build a very basic user login. I'm trying to create a user, then login with those credentials and get back a JSON Web Token. Where I'm stuck is trying to compare the passwords then send a response. </p>

<p>Steps:</p>

<p>Create User:</p>

<ol>
<li>enter email and password</li>
<li>salt/hash user password</li>
<li>store user into database</li>
<li>return success</li>
</ol>

<p>Login</p>

<ol>
<li>find user by request email value</li>
<li>if found compare passwords</li>
<li>passwords good send JSON Web Token</li>
</ol>

<p><strong>User Model</strong></p>

<pre><code>email:{ 
  type: String,
  required: true,
  unique: true
},
password: {
  type: String,
  required: true
}
</code></pre>

<p><strong>User Routes</strong></p>

<pre><code>var express     = require('express');
var router      = express.Router();
var jwt         = require('jsonwebtoken');
var bcrypt      = require('bcryptjs');

// Create User
...
bcrypt.genSalt(10, function(err, salt) {
    bcrypt.hash("superSecret", salt, function(err, hash) {
      user.password = hash;
      user.save();
      res.json({success: true, message: 'Create user successful'});
    });
  });
...

// Login
...
bcrypt.compare(req.body.password, 'superSecret', function(err, res) {
  if(req.body.password != user.password){
    res.json({success: false, message: 'passwords do not match'});
  } else {
    // Send JWT
  }
});
</code></pre>

<p>So the two problems here is that, I can't send a response nor can I compare the password. Just completely stuck on this, any help would be greatly appreciated. </p>