mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-06-16 03:20:27 +02:00
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.
This commit is contained in:
@@ -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(' ');
|
||||
|
||||
Reference in New Issue
Block a user