Closed rakanalh closed 8 years ago
No never 200 or 201 when it fails to save, an error has to be indicated when an error is present. For conflicting data though (not invalid data) I prefer using 409 CONFLICT, it's a semi-standard REST convention.
I think however a more interesting approach would be kind of a get_or_create on the token and device_type. Consider an application where a user logs out and logs in with another account, upon authentication the token registration will fail because it's associated with the first user.
Instead I'd prefer the device token being updated to the second user when he/she registers with it, but doing ONLY that has some security implications. Allowing such a method will also require a way to verify the device registering as well, to make sure it's the same device doing both requests.
Thank you for the input! I'll see what i will be doing about this one.
Users of Django-Pushy,
Feedback is required about this issue. Would you think it's best if django-pushy returns 201 or 200 responses on non-unique key & type combination?
The current implementation returns a 400 BAD REQUEST response with the following body:
Thoughts needed on this one.