Change the authorization header to X-Token
This commit is contained in:
parent
ae406f07ac
commit
19f2706dc8
@ -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,
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user