Local authentication

This commit is contained in:
NGPixel
2016-10-30 23:03:36 -04:00
parent dc6fc449f0
commit 3d20fee5df
8 changed files with 90 additions and 42 deletions

View File

@@ -78,9 +78,8 @@ userSchema.statics.hashPassword = (rawPwd) => {
};
userSchema.methods.validatePassword = function(rawPwd) {
let self = this;
return bcrypt.hash(rawPwd).then((pwd) => {
return (self.password === pwd) ? true : Promise.reject(new Error('Invalid Password'));
return bcrypt.compare(rawPwd, this.password).then((isValid) => {
return (isValid) ? true : Promise.reject(new Error('Invalid Login'));
});
};