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(
|
def get_by_token(
|
||||||
cls: type[SQLModel], request: Request, session: SessionDep
|
cls: type[SQLModel], request: Request, session: SessionDep
|
||||||
) -> SQLModel:
|
) -> SQLModel:
|
||||||
authorization = request.headers.get("Authorization")
|
token = request.headers.get("X-Token")
|
||||||
if authorization is None:
|
if token is None:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
detail="No authentication provided",
|
detail="No token provided",
|
||||||
status_code=400,
|
|
||||||
)
|
|
||||||
|
|
||||||
auth_type, token = authorization.split(" ")
|
|
||||||
if auth_type != "Token":
|
|
||||||
raise HTTPException(
|
|
||||||
detail="Invalid token type provided",
|
|
||||||
status_code=400,
|
status_code=400,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user