title: bcryptjs comparePassword always returns false - NodeJS
body: <p>I have looked at the other answers to the question on here but still not getting anywhere. I cannot get the <code>comparePassword</code> function to return true</p>
  
  <pre><code>module.exports.createUser = function(newUser, callback) {
    bcrypt.genSalt(10, function(err, salt){
      bcrypt.hash(newUser.password, salt, function(err, hash){
        newUser.password = salt;
        newUser.save(callback);
      });
    });
  };
  
  module.exports.comparePassword = function(candidatePassword, hash, callback){
    console.log("Provided password is " + candidatePassword);
    console.log("Provided hash is " + hash);
    bcrypt.compare(candidatePassword, hash, function(err, isMatch) {
      if(err) throw err;
        console.log(isMatch);
        callback(null, isMatch);
      });
  }
  </code></pre>
  
  <p>So if we take the user in test at this stage you can see their data</p>
  
  <pre><code>{ _id: 5aec6f702a4a181f261a43fe,
    full_name: 'Its me',
    username: 'myusername',
    email: 'myemail@gmail.com',
    tel_number: '12345678',
    password: '$2a$10$6GCgZDt.FL/eeZ1NsDASe.', // text version = test
    __v: 0
  }
  </code></pre>
  
  <p>When <code>comparePassword</code> is run the console logs return</p>
  
  <pre><code>Provided password is test
  Provided hash is $2a$10$6GCgZDt.FL/eeZ1NsDASe.
  </code></pre>
  
  <p>So to me they match right?</p>
  
  <p>Not sure what is going on here.</p>