Auth: resetPassword invalid token response status code from 500 to 400 or 403? #4909
edtorba
started this conversation in
Feature Requests & Ideas
Replies: 1 comment 16 replies
-
I agree with returning 403 status instead of 500. Because it is a breaking change though, I would open this as a PR against what will be the 3.0 branch when that is ready to contribute to. Are you interested in making a PR? |
Beta Was this translation helpful? Give feedback.
16 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When resetting the password via
resetPassword
, if an incorrect token is provided, an error is received from the API. While receiving a 500 status code is acceptable (ish?), it seems more appropriate in this instance to use a 400 (Bad Request) or 403 (Forbidden) status code.The definition for the 500 status code is as follows:
However, in our case, the server is aware of the situation, and I believe a 400 (Bad Request) status code, indicating that the server cannot or will not process the request due to something perceived as a client error, or a 403 (Forbidden) status code, indicating that the server understands the request but refuses to authorise it, would be more appropriate in this instance.
In terms of effort, the required change is straightforward; it simply involves adding an extra argument to set the appropriate status code.
resetPassword.ts
payload/packages/payload/src/auth/operations/resetPassword.ts
Line 70 in b40e9f8
APIError.ts
payload/packages/payload/src/errors/APIError.ts
Line 41 in b40e9f8
Beta Was this translation helpful? Give feedback.
All reactions