From 8f09b8b776c1d9e6d9662112c65a47f4fa83ebef Mon Sep 17 00:00:00 2001 From: Kentaro Wakayama Date: Wed, 16 Apr 2014 09:51:31 +0200 Subject: [PATCH] Add check of password and salt in user auth --- app/models/user.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/user.js b/app/models/user.js index cfd122a0..0bf0c492 100755 --- a/app/models/user.js +++ b/app/models/user.js @@ -104,6 +104,9 @@ 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); };