Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions backend/models/userModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions frontend/src/components/reg-auth/LoginForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ function LoginForm() {
{loading ? 'Signing In...' : 'Sign In'}
</SpaceBtn>

<Link to='/'>
<Button className='block w-full text-center' disabled={loading}>
Return to Home
</Button>
</Link>
<Button
href='/'
className='block w-full text-center'
disabled={loading}
>
Return to Home
</Button>
</div>

<p className='mt-4 text-center text-text-muted text-sm'>
Expand Down