Fix #19: 201 status code on successful registration

This commit is contained in:
François Voron
2019-10-19 18:36:57 +02:00
parent a4171f8bea
commit 5d4979f9a9
3 changed files with 5 additions and 3 deletions

View File

@@ -14,7 +14,7 @@ Register a new user.
}
```
!!! success "`200 OK`"
!!! success "`201 Created`"
```json
{
"id": "57cbb51a-ab71-4009-8802-3f54b4f2e23",

View File

@@ -32,7 +32,9 @@ def get_user_router(
on_after_forgot_password
)
@router.post("/register", response_model=models.User)
@router.post(
"/register", response_model=models.User, status_code=status.HTTP_201_CREATED
)
async def register(user: models.UserCreate): # type: ignore
existing_user = await user_db.get_by_email(user.email)

View File

@@ -84,7 +84,7 @@ class TestRegister:
def test_valid_body(self, test_app_client: TestClient):
json = {"email": "lancelot@camelot.bt", "password": "guinevere"}
response = test_app_client.post("/register", json=json)
assert response.status_code == status.HTTP_200_OK
assert response.status_code == status.HTTP_201_CREATED
response_json = response.json()
assert "hashed_password" not in response_json