SurfSense/surfsense_backend/app/schemas/users.py

24 lines
479 B
Python
Raw Normal View History

2025-03-14 18:53:14 -07:00
import uuid
2025-03-14 18:53:14 -07:00
from fastapi_users import schemas
2025-03-14 18:53:14 -07:00
class UserRead(schemas.BaseUser[uuid.UUID]):
pages_limit: int
pages_used: int
Epic 5 Complete: Billing, Subscriptions, and Admin Features Resolve all 5 deferred items from Epic 5 adversarial code review: - Migration 124: Add CASCADE to subscriptionstatus enum drop (prevent orphaned references) - Stripe rate limiting: In-memory per-user limiter (20 calls/60s) on verify-checkout-session - Subscription request cooldown: 24h cooldown before resubmitting rejected requests - Token reset date: Initialize on first subscription activation - Checkout URL validation: Confirmed HTTPS-only (Stripe always returns HTTPS) Implement Story 5.4 (Usage Tracking & Rate Limit Enforcement): - Page quota pre-check at HTTP upload layer - Extend UserRead schema with token quota fields - Frontend 402 error handling in document upload - Quota indicator in dashboard sidebar Story 5.5 (Admin Seed & Approval Flow): - Seed admin user migration with default credentials warning - Subscription approval/rejection routes with admin guard - 24h rejection cooldown enforcement Story 5.6 (Admin-Only Model Config): - Global model config visible across all search spaces - Per-search-space model configs with user access control - Superuser CRUD for global configs Additional fixes from code review: - PageLimitService: PAST_DUE subscriptions enforce free-tier limits - TokenQuotaService: PAST_DUE subscriptions enforce free-tier limits - Config routes: Fixed user_id.is_(None) filter on mutation endpoints - Stripe webhook: Added guard against silent plan downgrade on unrecognized price_id All changes formatted with Ruff (Python) and Biome (TypeScript). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-15 03:54:45 +07:00
monthly_token_limit: int
tokens_used_this_month: int
plan_id: str
subscription_status: str
display_name: str | None = None
avatar_url: str | None = None
2025-03-14 18:53:14 -07:00
2025-03-14 18:53:14 -07:00
class UserCreate(schemas.BaseUserCreate):
pass
2025-03-14 18:53:14 -07:00
class UserUpdate(schemas.BaseUserUpdate):
display_name: str | None = None
avatar_url: str | None = None