RESTful reset password and confirm email

前端 未结 7 1973
故里飘歌
故里飘歌 2021-02-08 08:36

im thinking what is the best RESTful way how confirm email and request reseting password. Im only aiming to find correct URI...

confirm email

PUT /users/{u

7条回答
  •  说谎
    说谎 (楼主)
    2021-02-08 09:19

    Firstly, I don't think that PUT is the right method for this. PUT broadly means "put this here", where the URL is identifying where the content should be located. You're really asking an existing resource to perform some action, which makes POST more correct.

    To answer your direct question, a RESTful URL should identify the resource you want to handle your request. In this case, the resource is either the user, or some password-resetting resource within the user.

    My preference would be for a password-resetting resource:

    POST /users/{userid}/password-reset

    This makes sense from a HTTP point of view, since you could issue a GET on the resource and receive something which indicates how to action a password reset (e.g. a HTML form prompting for the email address of the associated account).

    EDIT:

    For the purposes of email validation, there are two obvious options. You could either POST to a "confirm email" resource with the email address and confirmation data, to ask the server to process the confirmation, or you can execute a PUT to put the confirmation information on the server:

    POST /users/{userid}/confirm-email

    or

    PUT /users/{userid}/email-confirmation

提交回复
热议问题