Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Solves User model validation bug
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mleanos committed Oct 5, 2015
1 parent 7a9ee53 commit 288f0b4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/users/server/models/user.server.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ');
Expand Down

0 comments on commit 288f0b4

Please sign in to comment.