feat: foundations for the manager conversion (platform-v2 step 6.1)
- Backend: every HTTPException in routers/ is an error code now (260 raises, ~105 new codes, texts in en + el); XeniaError(detail=...) keeps the three v1-shaped answers old pages read; bad / unknown tokens answer auth.session_ended; test_errors refuses new HTTPExceptions. - Manager: v2.json is the list of pages on the v2 rules: scripts/lint.mjs lints them, tests/v2-guards.test.mjs refuses Greek and colour literals, `strict` paths make set-state-in-effect an error. - src/live/useLiveQuery.js (react-query + live events + refresh on reconnect); Signed in now uses it. - Dead manager files removed (3.1k lines unreachable from main.jsx). - Tests: backend 544 passed, manager unit 33, run-all (no Android) passed (manager's live bell check passed on a rerun). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from core.timeutil import utcnow
|
||||
import jwt
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from fastapi import Depends, HTTPException, Request, status
|
||||
from fastapi import Depends, Request, status
|
||||
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
@@ -67,7 +67,7 @@ def decode_session(token: str, db: Session | None = None):
|
||||
except jwt.ExpiredSignatureError:
|
||||
raise XeniaError("auth.session_ended")
|
||||
except jwt.InvalidTokenError:
|
||||
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid token")
|
||||
raise XeniaError("auth.session_ended")
|
||||
return payload, sessions.validate(payload.get("sid"), db)
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ def user_from_token(token: str, request: Request, db: Session):
|
||||
return make_support_user(), payload.get("sid")
|
||||
user = db.query(User).filter(User.id == int(payload["sub"]), User.is_active == True).first()
|
||||
if not user:
|
||||
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="User not found")
|
||||
raise XeniaError("auth.session_ended")
|
||||
set_log_context(user=user.id)
|
||||
return user, payload.get("sid")
|
||||
|
||||
@@ -115,6 +115,7 @@ get_current_user.__xenia_access__ = ("signed_in",)
|
||||
# Kept as aliases so the ~200 existing route signatures stay as they are. New code
|
||||
# uses core.access.deps.require("<key>") directly.
|
||||
from core.access.deps import require # noqa: E402
|
||||
from core.errors import XeniaError
|
||||
|
||||
require_manager = require("core.dashboard.access")
|
||||
require_staff_manager = require("core.staff.manage")
|
||||
|
||||
Reference in New Issue
Block a user