Skip to content

Fix #1222: Handle unregistered email in forgot password route with 404 #1232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sudip22-p
Copy link

@sudip22-p sudip22-p commented Mar 18, 2025

Forgot Password Functionality - Error Handling Update

Description

This update improves the error handling and response structure for the forgot password functionality:

  • Email input validation: Returns 400 Bad Request for invalid emails.
  • Returns a 404 Not Found if the provided email is not registered.
  • Used upsert: true for reset token updates to ensure token is either created or updated correctly.
  • Wrapped the entire function in a try-catch block to handle unexpected errors and return 500 Internal Server Error when needed.

Related Issues

-#1222

Steps to Test

  1. Test with a registered email:

    • Ensure a reset token is generated, and an email is sent to the user.
  2. Test with an unregistered email:

    • Confirm that a 404 Not Found response is returned with the message:
      • "No account with this email has been registered."
  3. Test with an invalid email format:

    • Verify a 400 Bad Request response is returned with the message:
      • "Invalid email."

Checklist

  • I have tested these changes.
  • I have updated the relevant documentation.
  • I have commented my code, particularly in hard-to-understand areas.
  • My changes generate no new warnings or errors.
  • The title of my pull request is clear and descriptive.

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.

1 participant