Skip to content

Conversation

@abhijit1859
Copy link
Contributor

@abhijit1859 abhijit1859 commented Oct 22, 2025

Implement Secure Password Reset Flow

This PR implements the forgot password and reset password functionality with email verification using a resendable token.

Changes Made

  1. Forgot Password (forgotPassword)

Accepts user email from the request.

Generates a JWT reset token valid for 1 hour.

Saves the token in the user’s refreshToken field.

Sends an email to the user with a password reset link.

Returns a success message if the email is sent, or an error if the user is not found.

  1. Reset Password (resetPassword)

Accepts reset token from URL params and new password from request body.

Verifies the token and checks if it matches the stored refreshToken.

Updates the user’s password and clears the refreshToken.

Returns a success message on successful reset, or an error for invalid/expired tokens.

Testing Instructions

Make a POST request to /api/auth/forgotPassword with the user email.

Check the email for the reset link.

Make a POST request to /api/auth/resetPassword/:token with the new password.

Confirm that the password is updated and the token cannot be reused.

Screenshot 2025-10-22 152210 Screenshot 2025-10-22 152504 Screenshot 2025-10-22 152611

@abhijit1859 abhijit1859 changed the title Feat/middleware rbac Implement Secure Password Reset Flow Oct 22, 2025
@Somilg11 Somilg11 merged commit 5220c55 into OPCODE-Open-Spring-Fest:main Oct 22, 2025
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants