big update new dashboard and import export

This commit is contained in:
2026-04-10 00:39:35 +05:00
parent 4013701441
commit e2fb4ddb2a
19 changed files with 1324 additions and 159 deletions

View File

@@ -50,6 +50,18 @@ async def login(username: str, password: str) -> tuple[str | None, str | None]:
return None, f"Ошибка: {e}"
async def logout(token: str) -> None:
"""POST /auth/logout — инвалидирует токен на сервере (Redis блэклист)."""
try:
async with httpx.AsyncClient(base_url=API_URL, timeout=_TIMEOUT) as client:
await client.post(
"/auth/logout",
headers={"Authorization": f"Bearer {token}"},
)
except Exception:
pass # даже если сервер недоступен — локальный logout всё равно произойдёт
async def get_me(token: str) -> dict | None:
"""GET /users/me — данные текущего пользователя."""
try:

View File

@@ -37,7 +37,10 @@ class AuthService:
return await api_client.get_me(token)
async def logout(self):
"""Удаляет токен — пользователь разлогинен."""
"""Инвалидирует токен на сервере и удаляет локальную сессию."""
token = self._page.session.store.get(_TOKEN_KEY)
if token:
await api_client.logout(token)
self._page.session.store.remove(_TOKEN_KEY)
self._page.session.store.remove("user_id")
self._page.session.store.remove("url_key")