feat: implement forgot password endpoint#40
Merged
ayshadogo merged 4 commits intoDfunder:mainfrom Mar 5, 2026
Merged
Conversation
Add POST /api/auth/forgot-password to allow users to request a password reset via email. The endpoint finds the user by email, generates a secure SHA-256 hashed reset token with 1-hour expiry, and sends a password reset email using the existing email service and template. Always returns HTTP 200 regardless of whether the email exists to prevent user enumeration. Closes Dfunder#25 Made-with: Cursor
Made-with: Cursor
Contributor
|
Please resolve conflicts |
Contributor
Author
|
@ayshadogo done, please check it out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
POST /api/auth/forgot-passwordendpoint that allows users to request a password reset via email (resolves Implement Forgot Password Endpoint #25)sendEmailservice andpasswordResetTemplateFRONTEND_URLto.env.examplefor constructing the reset linkChanges
src/controllers/auth.controller.jsforgotPasswordcontroller with token generation, hashing, and email dispatchsrc/routes/auth.routes.jsPOST /forgot-passwordroute with validationsrc/validators/auth.validators.jsforgotPasswordSchema(validates email in request body).env.exampleFRONTEND_URLenvironment variableTest plan
POST /api/auth/forgot-passwordwith a registered email — verify 200 response and email received with valid reset linkPOST /api/auth/forgot-passwordwith a non-existent email — verify 200 response with same generic message (no user enumeration)POST /api/auth/forgot-passwordwith invalid email format — verify 400 validation errorPATCH /api/auth/reset-password/:tokento confirm the full flow works end-to-endCloses #25