shotvibe / shotvibe-web

ShotVibe REST API webservice
1 stars 0 forks source link

Add REST endpoint for setting user nickname #1

Closed benny-shotvibe closed 11 years ago

benny-shotvibe commented 11 years ago

This should be something simple like POST /users/nickname/ with a JSON request body of

{ "nickname": "John Smith" }

Please let me know if you think there is a better way

prudnikov commented 11 years ago

I guess user should be able to set not just username, but email, first name, last name, may be something else. Then why create special endpoint for nickname? As a general rule for REST it should be /users/, /users/{user_id}. In this case user could send POST /users/{user_id} where user_id is his ID, on the server we will validate that user_id matches authenticated user's ID. Also we could change avatar upload url to /users/{user_id}/avatar with the same user_id validation.

benny-shotvibe commented 11 years ago

Yes, all this looks good, please do it this way.

Right now we only need support for setting the "nickname" field of the user, but we will add email and more things in the future

prudnikov commented 11 years ago

PATCH request should be used to update user's nickname because it is partial update.

prudnikov commented 11 years ago

If user tries to update someone else's profile by sending PUT or POST to an url /users/{user_id}/ where user_id is other than his ID OR tries to change other than allowed attributes server will return 403 Forbidden.