feat(sub): handling upgrade/downgrade

rw integration and /me endpoints are left
This commit is contained in:
2026-08-02 14:16:57 +07:00
parent 24f857ef1b
commit 97a4e819d6
10 changed files with 401 additions and 58 deletions

View File

@@ -6,6 +6,7 @@ from core.auth import jwt
from db.session import get_db
from external.pally import PallyClient
from schemas.dto import AuthContext
from services.subscriptions import sync_user_subscription
async def get_auth_context(
@@ -18,7 +19,10 @@ async def get_auth_context(
if auth.startswith("Bearer"):
token = auth.removeprefix("Bearer ").strip()
return await jwt.authorize(token, session)
ctx = await jwt.authorize(token, session)
await sync_user_subscription(session, user=ctx.user)
await session.commit()
return ctx
def get_pally_client() -> PallyClient: