Unauthenticated users
We make a PUT request to the api/v1/account/password endpoint and request a parameter with the corresponding email address to determine the account for which the user wants to reset (update) the password:
PUT : /api/v1/account/password?email={email@example.com}
Note. As @DougDomeny noted in his comment, sending an email as a query string in a URL is a security risk. GET parameters are not displayed when using https (and you should always use the correct https connection for such requests), but there are other security risks. You can read more on this topic in this blog here .
Passing an email in the body of the request would be a safer alternative to passing it as a GET parameter:
PUT : /api/v1/account/password
Request body:
{ "email": "email@example.com" }
The answer has 202 accepted values, meaning:
The request was accepted for processing, but the processing was not completed. The request may or may not ultimately be processed, as it may be rejected when the processing actually takes place. There is no way to resend the status code from an asynchronous operation such as this.
The user will receive an email at email@example.com and the processing of the update request depends on the actions taken by the link from the email.
https:
Opening a link from this email will result in a password form for resetting in the external interface application, which uses a password token to reset from the link as input for a hidden input field (the token is part of the link as a query string). Another input field allows the user to set a new password. The second input to confirm the new password will be used for verification on the external interface (to prevent typos).
Note. It can also be mentioned in the letter that if the user has not initialized the password reset, he / she can ignore the email and continue to use the application in normal mode with his current password.
When a form is submitted with a new password and token as input, a password reset process occurs. The form data will be sent again with a PUT request, but this time with a token, and we will replace the resource password with a new value:
PUT : /api/v1/account/password
Request body:
{ "token":"1234567890", "new":"password" }
Answer will be 204 no answer
The server has completed the request, but it does not need to return the body of the object, and it may want to return updated meta-information. The answer MAY include new or updated meta-information in the form of object headers, which, if present, MUST be associated with the requested option.
Authenticated Users
For authenticated users who want to change their password, the PUT request can be executed immediately without email (the account for which we update the password is known to the server). In this case, two fields will be sent to the form:
PUT : /api/v1/account/password
Request body:
{ "old":"password", "new":"password" }