diff --git a/backend/models/userModel.js b/backend/models/userModel.js index 7a0f655..7bd3a7d 100644 --- a/backend/models/userModel.js +++ b/backend/models/userModel.js @@ -36,17 +36,11 @@ const userSchema = new mongoose.Schema( ); // Hash password before saving -userSchema.pre('save', async function (next) { - if (!this.isModified('password')) return next(); +userSchema.pre('save', async function () { + if (!this.isModified('password')) return; - try { - const salt = await bcrypt.genSalt(10); - this.password = await bcrypt.hash(this.password, salt); - next(); - } catch (err) { - console.error('Error hashing password:', err); - next(err); - } + const salt = await bcrypt.genSalt(10); + this.password = await bcrypt.hash(this.password, salt); }); // Method to compare passwords diff --git a/frontend/src/components/reg-auth/LoginForm.jsx b/frontend/src/components/reg-auth/LoginForm.jsx index 83cb580..ff80471 100644 --- a/frontend/src/components/reg-auth/LoginForm.jsx +++ b/frontend/src/components/reg-auth/LoginForm.jsx @@ -98,11 +98,13 @@ function LoginForm() { {loading ? 'Signing In...' : 'Sign In'} - - - +