V8-archive: Create new error code for invalid login entity

Created on 8 Aug 2019  路  5Comments  路  Source: directus/v8-archive

When the user logs in through /auth/authenticate with an invalid email address, the API returns with an error code 4 with a message of email: This value is not a valid email address..

Authentication errors are all scoped in the 100 range, except for the 422 error on auth. Should we add a 0109 error code for the "Invalid email provided" error?

Ref: https://github.com/directus/app/issues/1801

enhancement

Most helpful comment

Theoretically when logging in, you should never see "Email is invalid" or "Password is invalid", however, "Email or Password is invalid" would be okay imo.

All 5 comments

Theoretically when logging in, you should never see "Email is invalid" or "Password is invalid", however, "Email or Password is invalid" would be okay imo.

That's already the case @shealavington. This error is not for "wrong username/password" this is for invalid payloads eg an email that's "rijk#rngr.org" or a password that's empty.

To clarify,

  1. 4XX (like 422) are HTTP STATUS code
  2. 100 (like Authentication errors, and other errors) are Directus defined error code

To make cleaner error code, as @WoLfulus suggested on #1104
Instead of using numbered error code (like 0100, 0101) we can use the text (like EMAIL_NOT_FOUND, INVALID_TOKEN)

And along with text error code, we also supply the appropriate HTTP STATUS code.

Additionally, we can create one endpoint (like GET /errors) to list out all the possible error code along with messages. So App can use that endpoint and display user-friendly error msg.

I like the idea of using string based error codes, but that doesn't negate this original request 馃槈

Additionally, we can create one endpoint (like GET /errors) to list out all the possible error code along with messages. So App can use that endpoint and display user-friendly error msg.

I think we don't need this, all the error codes will have a description in the languages files in the Directus app itself. The API doesn't have any localization, so those strings won't be used most likely

Fixed in #1218

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ondronix picture ondronix  路  3Comments

jwkellyiii picture jwkellyiii  路  3Comments

metalmarco picture metalmarco  路  3Comments

Nitwel picture Nitwel  路  3Comments

Varulv1997 picture Varulv1997  路  3Comments