Skip to content

Commit f6ca289

Browse files
kerimdzhanovAwk34
authored andcommitted
fix(model:user): add missing return statements
Add `return` statements to the user model's pre-save hook to prevent function execution if an error is occurred
1 parent 67257d4 commit f6ca289

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: app/templates/server/api/user(auth)/user.model(mongooseModels).js

+3-3
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,18 @@ UserSchema
109109
}
110110

111111
if (!validatePresenceOf(this.password)<% if (filters.oauth) { %> && authTypes.indexOf(this.provider) === -1<% } %>) {
112-
next(new Error('Invalid password'));
112+
return next(new Error('Invalid password'));
113113
}
114114

115115
// Make salt with a callback
116116
this.makeSalt((saltErr, salt) => {
117117
if (saltErr) {
118-
next(saltErr);
118+
return next(saltErr);
119119
}
120120
this.salt = salt;
121121
this.encryptPassword(this.password, (encryptErr, hashedPassword) => {
122122
if (encryptErr) {
123-
next(encryptErr);
123+
return next(encryptErr);
124124
}
125125
this.password = hashedPassword;
126126
next();

0 commit comments

Comments
 (0)