|
|
|
@ -19,17 +19,21 @@ module.exports = function(User) {
|
|
|
|
|
User.isPasswordCorrect = function(uid, password, callback) {
|
|
|
|
|
password = password || '';
|
|
|
|
|
async.waterfall([
|
|
|
|
|
function (next) {
|
|
|
|
|
User.isPasswordValid(password, next);
|
|
|
|
|
},
|
|
|
|
|
function (next) {
|
|
|
|
|
db.getObjectField('user:' + uid, 'password', next);
|
|
|
|
|
},
|
|
|
|
|
function (hashedPassword, next) {
|
|
|
|
|
if (!hashedPassword) {
|
|
|
|
|
return callback();
|
|
|
|
|
return callback(null, true);
|
|
|
|
|
}
|
|
|
|
|
Password.compare(password, hashedPassword, next);
|
|
|
|
|
|
|
|
|
|
User.isPasswordValid(password, function(err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Password.compare(password, hashedPassword, next);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
], callback);
|
|
|
|
|
};
|
|
|
|
|