Bycrpt password comparing always returns false mongoose
<p>I am sorry for posting this question again since it has been asked before. But none of the solutions work for me. 
I am hashing the password and then saving it to the db. (While saving if I compare password and hash it returns true)</p>

<p>UserSchema.pre('save', function(next) {
  console.log("Unhashed Password: " + this.password );</p>

<pre><code>  if (this.password &amp;&amp; this.password.length &gt; 6) {
    var password = this.password;
    console.log("User password is valid");
    bcrypt.hash(password, 10, function (err, hash) {
      if (err) {
        var err = new Error("Error hashing password");
        next(err);
      } else {
        this.hashed_password = hash;
        console.log("Hash: " + hash);
        bcrypt.compare(password, this.hashed_password, function (err, result) {
          console.log("Checking hash and password. Result is" + result);
          console.log("Checking hash and password. Error is" + err);
          next();
        });
      }
    });
  }
});
</code></pre>

<p>It logs: </p>

<pre><code>Unhashed Password: kashifLatif
User password is okay
Hash: $2a$10$fOuyx0XlTQ2Rwvc1jhn.EuC4UXt5oCrgTkhT.GviQh2Ftjtkuzy1C
Checking hash and password. Result istrue
Checking hash and password. Error isundefined
</code></pre>

<p>But when I try to log in with same credentials, it the bcrypt compare function returns false:
(Authentication function):
        User.load(options, function (err, user) {</p>

<pre><code>    User.load(options, function (err, user) {

           console.log("Load user callback");
            if (err) return done(err);
            console.log("Db didn't return error");
            if (!user) {
                console.log("User didn't exist error");
                return done(null, false, { message: 'Unknown user' });
            }
            console.log("Password sent from client: "+ password)
            console.log("Email: "+ user.email)
            console.log("Hashed: "+ user.hashed_password)
            bcrypt.compare(password, user.hashed_password,function(err, result){
                console.log("Bycrpt compared didn't exist error. Result is" + result);
                if(result)
                    return done(null, user);
                else
                    return done(null, false, { message: 'Invalid password' });
            });
        }
    );
</code></pre>

<p>It logs: </p>

<pre><code>Load user callback
Db didn't return error
Password sent from client: kashifLatif
Email: usmann@gmail.com
Hashed: ad9da4c72ed234220315af53fb113f1f7716a8a0
Bycrpt compared didn't exist error. Result isfalse
</code></pre>

<p>The hash when saving is not the same as the hash when retrieving it. Why is that the case?</p>