diff --git a/app/templates/server/api/user(auth)/user.model(mongooseModels).js b/app/templates/server/api/user(auth)/user.model(mongooseModels).js index 201afb4bc..008412eaf 100644 --- a/app/templates/server/api/user(auth)/user.model(mongooseModels).js +++ b/app/templates/server/api/user(auth)/user.model(mongooseModels).js @@ -102,7 +102,7 @@ var validatePresenceOf = function(value) { UserSchema .pre('save', function(next) { // Handle new/update passwords - if (this.password) { + if (this.isModified('password')) { if (!validatePresenceOf(this.password)<% if (filters.oauth) { %> && authTypes.indexOf(this.provider) === -1<% } %>) { next(new Error('Invalid password')); } diff --git a/app/templates/server/api/user(auth)/user.model(sequelizeModels).js b/app/templates/server/api/user(auth)/user.model(sequelizeModels).js index af593157a..776eafc3e 100644 --- a/app/templates/server/api/user(auth)/user.model(sequelizeModels).js +++ b/app/templates/server/api/user(auth)/user.model(sequelizeModels).js @@ -89,8 +89,9 @@ module.exports = function(sequelize, DataTypes) { }, beforeUpdate: function(user, fields, fn) { if (user.changed('password')) { - user.updatePassword(fn); + return user.updatePassword(fn); } + fn(); } },