forked from mtusi2026/mtusi2026lab2
Исправить logout при сбое записи в кэш сессий
This commit is contained in:
+3
-2
@@ -14,7 +14,7 @@ from starlette.concurrency import run_in_threadpool
|
||||
|
||||
from app import config
|
||||
from app.cache import REVOKED, SessionCache
|
||||
from app.errors import BASIC_CHALLENGE, unauthorized
|
||||
from app.errors import BASIC_CHALLENGE, ApiError, unauthorized
|
||||
from app.storage import Store, fmt_ts, user_row
|
||||
|
||||
_hasher = PasswordHasher()
|
||||
@@ -109,4 +109,5 @@ async def logout(store: Store, cache: SessionCache, header: Optional[str]) -> No
|
||||
if expires_at is None:
|
||||
raise unauthorized("session expired or revoked")
|
||||
remaining = int((expires_at - datetime.now(timezone.utc)).total_seconds()) + 1
|
||||
await cache.revoke(digest, remaining)
|
||||
if not await cache.revoke(digest, remaining):
|
||||
raise ApiError(503, "unavailable", "logout not confirmed by session cache, retry later")
|
||||
|
||||
Reference in New Issue
Block a user