Issue 103 | Implement password reset functionality #219
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request implements a complete password reset flow with two-factor verification, including backend logic, email delivery, and frontend integration. The changes add secure code generation and validation, update the user model to store verification codes, and provide user-friendly frontend forms and flows for requesting a password reset, verifying the code, and setting a new password.
Backend changes:
Password reset and verification logic:
authRoutes.tsfor sending a password reset verification code, verifying the code, and updating the password, including all necessary input validation and error handling.passwordReset.ts) for code generation, validation, and password update logic, ensuring security and clarity of the password reset process.User model updates:
Usermodel and schema to includetwoFactorCodeandtwoFactorCodeExpiryfields for storing password reset verification codes and their expiration times. [1] [2] [3]Email delivery:
EmailServiceutility to support Gmail SMTP and send styled password reset code emails. Added a method to send the verification code email to users. [1] [2]Frontend changes:
Password reset flow:
ForgotPasswordcomponent to call the backend, handle loading and errors, and redirect users to the 2FA code verification page after requesting a reset. [1] [2] [3] [4]NewPasswordcomponent to submit the new password to the backend, handle loading and errors, and redirect to a confirmation page on success. [1] [2] [3] [4]/reset-password.Minor improvements:
App.tsxand made minor formatting adjustments. [1] [2]These changes together provide a secure, user-friendly, and robust password reset experience for users.
Closes #103