diff --git a/backend/models/User.js b/backend/models/User.js index eb506ed5..3aeaf9b2 100644 --- a/backend/models/User.js +++ b/backend/models/User.js @@ -18,12 +18,12 @@ const UserSchema = new mongoose.Schema({ }, }); -// ✅ FIXED: no next() -UserSchema.pre('save', async function () { - if (!this.isModified('password')) return; +UserSchema.pre('save', async function (next) { + if (!this.isModified('password')) return next(); const salt = await bcrypt.genSalt(10); this.password = await bcrypt.hash(this.password, salt); + next(); }); // ✅ password comparison