3 lab
This commit is contained in:
@@ -17,6 +17,7 @@ from app.db import check_database_ready, engine, get_db
|
||||
from app.deps import basic_scheme, pagination_params, require_user
|
||||
from app.errors import (
|
||||
ApiError,
|
||||
InvalidRequest,
|
||||
Unavailable,
|
||||
api_error_handler,
|
||||
common_headers,
|
||||
@@ -217,6 +218,11 @@ async def login(
|
||||
db: AsyncSession = Depends(get_db),
|
||||
_basic: None = Security(basic_scheme),
|
||||
):
|
||||
# Contract: login takes only "Authorization: Basic", no request body.
|
||||
# Any body (malformed JSON, "{}", ...) is rejected before the password check.
|
||||
if await request.body():
|
||||
raise InvalidRequest("POST /auth/sessions does not accept a request body.")
|
||||
|
||||
return await create_user_session(
|
||||
db,
|
||||
request.headers.get("Authorization"),
|
||||
|
||||
Reference in New Issue
Block a user