Backend (replaces PHP api.php + auth.php): - FastAPI app with routers: jobs, auth, billing - Supabase JWT authentication in deps.py - Celery + Redis job queue (process_pdf_task) - MinIO S3-compatible storage service - PDF checker wrapper (delegates to enterprise_pdf_checker.py) - Stripe billing: checkout, portal, webhook handler Multi-tenancy (Phase 3): - Alembic migration 001: workspaces, workspace_members, jobs, usage_events - Row-Level Security on all tenant tables via app.workspace_id session var - Monthly quota enforcement per workspace (402 on exceeded) - Plan tiers: free(5) / pro(100) / business(unlimited) Config: - pydantic-settings based config.py (no hardcoded values) - docker-compose.yml rewritten: postgres, redis, minio, api, celery Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
31 lines
980 B
Python
31 lines
980 B
Python
"""Auth router — user profile, workspace info."""
|
|
from fastapi import APIRouter, Depends
|
|
from sqlalchemy import text
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
from app.db import get_db
|
|
from app.deps import CurrentUser, get_current_user
|
|
|
|
router = APIRouter(prefix="/api/v1/auth", tags=["auth"])
|
|
|
|
|
|
@router.get("/me")
|
|
async def get_me(
|
|
user: CurrentUser = Depends(get_current_user),
|
|
db: AsyncSession = Depends(get_db),
|
|
):
|
|
row = await db.execute(
|
|
text("SELECT id, name, slug, plan_tier, monthly_quota FROM workspaces WHERE id = :wid"),
|
|
{"wid": user.workspace_id},
|
|
)
|
|
workspace = row.fetchone()
|
|
return {
|
|
"user_id": user.user_id,
|
|
"email": user.email,
|
|
"workspace": {
|
|
"id": str(workspace.id),
|
|
"name": workspace.name,
|
|
"slug": workspace.slug,
|
|
"plan_tier": workspace.plan_tier,
|
|
"monthly_quota": workspace.monthly_quota,
|
|
} if workspace else None,
|
|
}
|