Blog_Website
Blog_Website copied to clipboard
Encrypted Password Before Storing
⚔️ Fixed issue #195
Successfully encrypted the password before storing in the database
Description I implemented password encryption using a Mongoose pre save hook to automatically hash user passwords before saving them to the database. This ensures that passwords are securely stored without exposing them in plain text.
Reason for Changes:
- Ensure the secure storage of user passwords by hashing them before saving to the database.
- Centralize password encryption logic within the model using Mongoose's pre hook, following the DRY principle.
- Improve code maintainability and security by avoiding manual password hashing in the controller.
Test Plan:
- Register a new user and verify that the password is hashed in the database.
- Validate that incorrect passwords still render the appropriate error messages.
- Test user login functionality with the hashed password.
This PR fixes #195