Created
August 19, 2014 15:20
-
-
Save tysonnero/e487ff61ac522976f3d8 to your computer and use it in GitHub Desktop.
UserSchema Pre-Validate Method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check password strength using OWASP module | |
UserSchema | |
.pre('validate', function (next) { | |
// Set options | |
owasp.config(config.password); | |
var result = owasp.test(this.password); | |
if (result.errors.length) { | |
// Join all errors in the array so only one error is returned | |
var error = result.errors.join(' '); | |
this.invalidate('password', error); | |
} | |
next(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment