Change the authorization header to X-Token

This commit is contained in:
PapaTutuWawa 2025-04-22 23:09:50 +02:00
parent ae406f07ac
commit 19f2706dc8

View File

@ -30,17 +30,10 @@ SessionDep = Annotated[Session, Depends(get_session)]
def get_by_token(
cls: type[SQLModel], request: Request, session: SessionDep
) -> SQLModel:
authorization = request.headers.get("Authorization")
if authorization is None:
token = request.headers.get("X-Token")
if token is None:
raise HTTPException(
detail="No authentication provided",
status_code=400,
)
auth_type, token = authorization.split(" ")
if auth_type != "Token":
raise HTTPException(
detail="Invalid token type provided",
detail="No token provided",
status_code=400,
)