Skip to content

Commit

Permalink
fix(model): fix update bugs with mongoose and sequelize
Browse files Browse the repository at this point in the history
  • Loading branch information
kingcody committed Jun 22, 2015
1 parent df48188 commit 1805975
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
},

Expand Down

0 comments on commit 1805975

Please sign in to comment.