We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 08ec6fb commit 3102e64Copy full SHA for 3102e64
backend/models/User.js
@@ -45,15 +45,14 @@ const UserSchema = new mongoose.Schema({
45
}
46
});
47
48
-// Encrypt password using bcrypt
49
-UserSchema.pre('save', async function (next) {
+// Encrypt password using bcrypt (Mongoose 9 async middleware - no next())
+UserSchema.pre('save', async function () {
50
if (!this.isModified('password')) {
51
- return next();
+ return;
52
53
54
const salt = await bcrypt.genSalt(10);
55
this.password = await bcrypt.hash(this.password, salt);
56
- next();
57
58
59
// Match user entered password to hashed password in database
0 commit comments