example: fix expiration

Co-authored-by: Simon Li <orpheus+devel@gmail.com>
This commit is contained in:
Min RK
2025-04-26 13:24:50 +02:00
committed by GitHub
parent b673fad94b
commit 798faaafe8

View File

@@ -81,7 +81,7 @@ async def login(token: Annotated[str, Body(embed=True)]):
status_code=status.HTTP_404_NOT_FOUND, content={"message": "invalid token"} status_code=status.HTTP_404_NOT_FOUND, content={"message": "invalid token"}
) )
username, expires_at = _tokens_to_username.pop(hashed_token) username, expires_at = _tokens_to_username.pop(hashed_token)
if expires_at > now: if expires_at < now:
return JSONResponse( return JSONResponse(
status_code=status.HTTP_400_BAD_REQUEST, status_code=status.HTTP_400_BAD_REQUEST,
content={"message": "token expired"}, content={"message": "token expired"},