feat: update datetime handling to use UTC and improve type annotations

This commit is contained in:
gabdevele
2026-04-12 20:25:30 +02:00 Unverified
parent cc8ae34838
commit 0ea45364bf
5 changed files with 26 additions and 15 deletions
+5 -4
View File
@@ -1,4 +1,5 @@
from datetime import datetime, timezone
from datetime import UTC, datetime
from typing import Annotated
from core.security import (
AuthContext,
@@ -32,9 +33,9 @@ async def login_handler(payload: LoginInput):
@router.post("/logout", status_code=status.HTTP_204_NO_CONTENT)
async def logout_handler(
auth_context: AuthContext = Depends(get_auth_context),
auth_context: Annotated[AuthContext, Depends(get_auth_context)],
) -> Response:
expires_at = datetime.fromtimestamp(auth_context.payload.exp, tz=timezone.utc)
if expires_at > datetime.now(timezone.utc):
expires_at = datetime.fromtimestamp(auth_context.payload.exp, tz=UTC)
if expires_at > datetime.now(UTC):
await revoke_token(jti=auth_context.payload.jti, expires_at=expires_at)
return Response(status_code=status.HTTP_204_NO_CONTENT)