Add invite code registration system for beta
Backend: - Add InviteCode model with single-use codes - Add invite API endpoints (create, list, revoke, validate) - Modify registration to require invite code when enabled - Add REQUIRE_INVITE_CODE config toggle (default: true) - Add Alembic migration for invite_codes table Frontend: - Add invite code field to registration page - Validate invite code on blur with visual feedback - Pass invite code to registration API Admins can generate invite codes via /api/docs (Swagger UI). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
34
backend/app/schemas/invite_code.py
Normal file
34
backend/app/schemas/invite_code.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from uuid import UUID
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class InviteCodeCreate(BaseModel):
|
||||
"""Schema for creating a new invite code."""
|
||||
expires_at: Optional[datetime] = Field(None, description="Optional expiration time")
|
||||
note: Optional[str] = Field(None, max_length=255, description="Note about who this code is for")
|
||||
|
||||
|
||||
class InviteCodeResponse(BaseModel):
|
||||
"""Schema for invite code response."""
|
||||
id: UUID
|
||||
code: str
|
||||
created_by_id: UUID
|
||||
used_by_id: Optional[UUID] = None
|
||||
expires_at: Optional[datetime] = None
|
||||
note: Optional[str] = None
|
||||
created_at: datetime
|
||||
used_at: Optional[datetime] = None
|
||||
is_used: bool
|
||||
is_expired: bool
|
||||
is_valid: bool
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class InviteCodeValidation(BaseModel):
|
||||
"""Schema for invite code validation response."""
|
||||
valid: bool
|
||||
message: str
|
||||
Reference in New Issue
Block a user