Skip to content

Fix Issue Handling in Forget Password Function #1222

@Rk-2005

Description

@Rk-2005

Description:
Currently, when a user enters an unregistered email in the forget password functionality, the server responds with a 500 Internal Server Error instead of a proper 404 Not Found message stating that the email is not registered. This happens because the code attempts to access user._id before checking if user is null.

Steps to Reproduce:

Send a POST request to the forget password endpoint with an unregistered email.

Observe that the server returns a 500 Internal Server Error with a message Cannot read properties of null (reading '_id') instead of a proper 404 response.

Expected Behavior:

The server should return a 404 Not Found with a message: No account with this email has been registered.

Image
How i khow my email is in correct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions