Blog_Website icon indicating copy to clipboard operation
Blog_Website copied to clipboard

Encrypted Password Before Storing

Open vishaltiwari012 opened this issue 1 year ago • 0 comments

⚔️ 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:

  1. Ensure the secure storage of user passwords by hashing them before saving to the database.
  2. Centralize password encryption logic within the model using Mongoose's pre hook, following the DRY principle.
  3. Improve code maintainability and security by avoiding manual password hashing in the controller.

Test Plan:

  1. Register a new user and verify that the password is hashed in the database.
  2. Validate that incorrect passwords still render the appropriate error messages.
  3. Test user login functionality with the hashed password.

This PR fixes #195

vishaltiwari012 avatar Oct 10 '24 18:10 vishaltiwari012