From 288f0b4e635b15261ef83b282a0b207549ed3445 Mon Sep 17 00:00:00 2001 From: mleanos Date: Mon, 5 Oct 2015 16:41:14 -0700 Subject: [PATCH] Solves User model validation bug This solves the issue of the User model's pre('validate') method, attempting to validate against a password that was not modified. Adds the this.isModified('password') check to the condition. --- modules/users/server/models/user.server.model.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/users/server/models/user.server.model.js b/modules/users/server/models/user.server.model.js index ca4d99edf3..ff7a3ef3f9 100644 --- a/modules/users/server/models/user.server.model.js +++ b/modules/users/server/models/user.server.model.js @@ -116,7 +116,7 @@ UserSchema.pre('save', function (next) { * Hook a pre validate method to test the local password */ UserSchema.pre('validate', function (next) { - if (this.provider === 'local' && this.password) { + if (this.provider === 'local' && this.password && this.isModified('password')) { var result = owasp.test(this.password); if (result.errors.length) { var error = result.errors.join(' ');