fix exit early when password is non-string

closes #1437
This commit is contained in:
Berkeley Martinez 2015-06-16 14:44:37 -07:00
parent 70ca7c51b4
commit 68fd106510
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