Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REST service: HTTP code for forcing a change of password

What is the correct HTTP status code that should be returned by a REST service when:

  1. The user has attempted to login with a first-time computer-generated password;
  2. The password provided by user is correct;
  3. The user must change the password before he/she can continue to do anything.
like image 624
Jai Avatar asked Aug 17 '17 05:08

Jai


People also ask

What is a 201 status code?

The HTTP 201 Created success status response code indicates that the request has succeeded and has led to the creation of a resource.

How do I reset my API password?

First, create a password recovery email, which includes a link (and recovery token) specific to this end user. Then, the end user can follow the link to a web page in Epicenter where they can reset their password. Alternatively, you can also use the Password API with this recovery token to update the password directly.


1 Answers

TLDR;

There is no built-in way of doing this. You will have to rely on home-made status codes and conventions.


I don't think that there is a built-in HTTP status code for a such thing.

All you can really do here is to return a 200 OK response and add in the content of the response body a message/code telling the user that they need to change their password. If they don't, the next time they attempt to login with the single-use password they should get a 401 unauthorized (and you can return in the body of the 401 a message telling them to change their password because they attempted to use an expired single-use password).

like image 97
Mathieu VIALES Avatar answered Oct 14 '22 08:10

Mathieu VIALES