danbretl / mid-tier

django webapp
1 stars 0 forks source link

Registration failure responses should be more easily differentiated #115

Open danbretl opened 12 years ago

danbretl commented 12 years ago

Currently, two situations are covered by the same 400 status code registration response - that the email is invalid, and that the email is already in use. It is possible to differentiate between the situations by looking at the text in the "email" field of the response:

{"email": ["Enter a valid e-mail address."]} {"email": ["A user is registered with this e-mail address."]}

However, checking for matches with that sort of specific natural language seems a poor and unreliable way for a client to determine what's going on, as the server may at some point in the future change a word or two.

It would be better to use different status codes for the different situations. One suggestion has been to use code 409 for the "email already in use" response. http://stackoverflow.com/questions/3825990/http-response-code-for-post-when-resource-already-exists