внес правки
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
2026-10-24 10:56:29 +03:00
parent 6dbc2da1ca
commit 5b15688149
19 changed files with 356 additions and 181 deletions
+10 -2
View File
@@ -33,13 +33,14 @@ async def create_session(user_id: str) -> dict:
return {
"token": token,
"token_type": "Bearer",
"expires_at": expires_at.isoformat().replace( "+00:00", "Z"),
"expires_at": expires_at.isoformat().replace("+00:00", "Z"),
}
async def delete_session(token: str) -> None:
await redis_client.delete(f"session:{token}")
async def get_current_user(credentials: HTTPAuthorizationCredentials = Depends(bearer_scheme)):
if not credentials:
raise HTTPException(
@@ -50,7 +51,14 @@ async def get_current_user(credentials: HTTPAuthorizationCredentials = Depends(b
token = credentials.credentials
user_id = await redis_client.get(f"session:{token}")
try:
user_id = await redis_client.get(f"session:{token}")
except Exception:
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="Внутренняя ошибка сервера"
)
if not user_id:
raise HTTPException(