I am new to nodejs but I am trying to use it as server for an online game I am designing. I come across the tutorial and I am just playing around with the code to see how I can modify it to suit me need. https://github.com/scotch-io/easy-node-authentication/tree/linking
1 thing I couldn't solve however is while using bcrypt, my code below is trying to isolate the issue:
//check-hash
var bcrypt   = require('bcrypt-nodejs');
var salt = bcrypt.genSaltSync(8);
var newAccount = {
    username: "admin",
    password: "1235",
    email: "test@domain.com",
    AccCreateOn: Date.now(),
    LastLogin: Date.now()
}
newAccount.generateHash  = function(password) {
    return bcrypt.hashSync(password,  salt);
};
// checking if password is  valid
newAccount.validPassword  = function(password) {
    return bcrypt.compareSync(password,  this.password);
};
console.log (newAccount.password);
newAccount.password = newAccount.generateHash(this.password);
console.log(newAccount.validPassword("1235")); //false
console.log(newAccount.validPassword("1236"));//false
I already figure out the line at fault is
return bcrypt.compareSync(password,  this.password);
which if I change this.password to newAccount.password it will work just fine.
what is wrong as I thought this.password in this context is newAccount.password, or is it not?
