Skip to content

Commit 3102e64

Browse files
committed
fix: Remove next() from Mongoose 9 async pre-save hook
1 parent 08ec6fb commit 3102e64

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

backend/models/User.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,14 @@ const UserSchema = new mongoose.Schema({
4545
}
4646
});
4747

48-
// Encrypt password using bcrypt
49-
UserSchema.pre('save', async function (next) {
48+
// Encrypt password using bcrypt (Mongoose 9 async middleware - no next())
49+
UserSchema.pre('save', async function () {
5050
if (!this.isModified('password')) {
51-
return next();
51+
return;
5252
}
5353

5454
const salt = await bcrypt.genSalt(10);
5555
this.password = await bcrypt.hash(this.password, salt);
56-
next();
5756
});
5857

5958
// Match user entered password to hashed password in database

0 commit comments

Comments
 (0)