mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2026-03-13 07:49:55 +08:00
Fix #19: 201 status code on successful registration
This commit is contained in:
@@ -14,7 +14,7 @@ Register a new user.
|
||||
}
|
||||
```
|
||||
|
||||
!!! success "`200 OK`"
|
||||
!!! success "`201 Created`"
|
||||
```json
|
||||
{
|
||||
"id": "57cbb51a-ab71-4009-8802-3f54b4f2e23",
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user