Change password of a user in a REST API -
i'm developing small rest api. have user resource fields in database:
{ email: string, password: string, first_name: string, last_name: string, age: number, location: string } when query specific user resource i'm returning fields except password field security reasons.
now want make form in client side user can update personal information , password. change password form have 2 inputs: old_password , new_password.
here comes doubt. want have put method can send fields , update user. old_password , new_password filled cannot send server every time user makes put request.
is ok send 2 fields put method? restful?
other idea have patch method 2 fields , update user password. put method not updating user password , it's not being correctly used right?
which restful approach? thanks.
yes can set default values when value doesn't exists or use flag on server check if value present. .., put have deliver full object resource. main reason of this, put should idempotent. means request, repeated should evaluate same result on server. if allow partial updates, cannot idem-potent anymore.
use patch method allows partially update structure. submits partial modification resource. if need update 1 field resource, may want use patch method.
Comments
Post a Comment