Skip to content

Commit

Permalink
Adding the salt part to the hashPassword FN
Browse files Browse the repository at this point in the history
  • Loading branch information
amoshaviv committed Apr 16, 2014
1 parent a976eb9 commit 09f1eab
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions app/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ UserSchema.pre('save', function(next) {
* Create instance method for hashing a password
*/
UserSchema.methods.hashPassword = function(password) {
if (password) {
if (this.salt && password) {
return crypto.pbkdf2Sync(password, this.salt, 10000, 64).toString('base64');
} else {
return password;
Expand All @@ -104,9 +104,6 @@ UserSchema.methods.hashPassword = function(password) {
* Create instance method for authenticating user
*/
UserSchema.methods.authenticate = function(password) {
if (!this.password || !this.salt) {
return false;
}
return this.password === this.hashPassword(password);
};

Expand Down

0 comments on commit 09f1eab

Please sign in to comment.