Skip to content

Conversation

@Shazzz135
Copy link
Collaborator

@Shazzz135 Shazzz135 commented Jan 18, 2026

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:

  • Added new endpoints to authRoutes.ts for sending a password reset verification code, verifying the code, and updating the password, including all necessary input validation and error handling.
  • Implemented a utility (passwordReset.ts) for code generation, validation, and password update logic, ensuring security and clarity of the password reset process.
  • Created a code generator utility for generating and hashing 6-digit codes, and for calculating code expiration.

User model updates:

  • Extended the User model and schema to include twoFactorCode and twoFactorCodeExpiry fields for storing password reset verification codes and their expiration times. [1] [2] [3]

Email delivery:

  • Enhanced the EmailService utility 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:

  • Updated the ForgotPassword component 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]
  • Improved the NewPassword component to submit the new password to the backend, handle loading and errors, and redirect to a confirmation page on success. [1] [2] [3] [4]
  • Updated routing to reflect the new password reset flow, renaming the route to /reset-password.

Minor improvements:

  • Fixed a BOM issue in App.tsx and made minor formatting adjustments. [1] [2]

These changes together provide a secure, user-friendly, and robust password reset experience for users.

Closes #103

@Shazzz135 Shazzz135 requested a review from Flapjacck January 19, 2026 00:06
@Flapjacck Flapjacck changed the title Issue 103 Issue 103 | Implement password reset functionality Jan 19, 2026
Copy link
Member

@Flapjacck Flapjacck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. make sure to close issue in comment in future

@Flapjacck Flapjacck merged commit 8e33665 into main Jan 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🔄 Implement password reset functionality

3 participants