added a new property to userData "hasPassword", disabling "current password" field in user editing if no password is set (for SSO logins, for example)

This commit is contained in:
Julian Lam
2014-03-06 15:32:06 -05:00
parent 4a1513eabf
commit e9e53ad95e
3 changed files with 19 additions and 10 deletions

View File

@@ -185,8 +185,13 @@ var bcrypt = require('bcryptjs'),
return callback(err);
}
if (data && data.password) {
delete data.password;
if (data) {
if (data.password) {
delete data.password;
data.hasPassword = true;
} else {
data.hasPassword = false;
}
}
callback(err, data);
});
@@ -467,13 +472,18 @@ var bcrypt = require('bcryptjs'),
return callback(err);
}
bcrypt.compare(data.currentPassword, currentPassword, function(err, res) {
if (err || !res) {
return callback(err || new Error('Your current password is not correct!'));
}
if (currentPassword !== null) {
bcrypt.compare(data.currentPassword, currentPassword, function(err, res) {
if (err || !res) {
return callback(err || new Error('Your current password is not correct!'));
}
hashAndSetPassword(callback);
});
} else {
// No password in account (probably SSO login)
hashAndSetPassword(callback);
});
}
});
}
};