Merge pull request #1465 from FreeCodeCamp/fix/no-password

fix: exit early when password is non-string
This commit is contained in:
Raymond Feng 2015-07-29 15:12:43 -07:00
commit 66d5cc07e0
1 changed files with 3 additions and 0 deletions

View File

@ -544,6 +544,9 @@ module.exports = function(User) {
this.settings.ttl = this.settings.ttl || DEFAULT_TTL;
UserModel.setter.password = function(plain) {
if (typeof plain !== 'string') {
return;
}
if (plain.indexOf('$2a$') === 0 && plain.length === 60) {
// The password is already hashed. It can be the case
// when the instance is loaded from DB