Yves Gugger bb7ce97330
Some checks failed
CI / Frontend Lint & Type Check (push) Has been cancelled
CI / Frontend Build (push) Has been cancelled
CI / Backend Lint (push) Has been cancelled
CI / Backend Tests (push) Has been cancelled
CI / Docker Build (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
Deploy / Build & Push Images (push) Has been cancelled
Deploy / Deploy to Server (push) Has been cancelled
Deploy / Notify (push) Has been cancelled
Deploy: referral rewards antifraud + legal contact updates
2025-12-15 13:56:43 +01:00

77 lines
1.9 KiB
Python

"""Authentication schemas."""
from datetime import datetime
from typing import Optional
from pydantic import BaseModel, EmailStr, Field
class UserCreate(BaseModel):
"""Schema for user registration."""
email: EmailStr
password: str = Field(..., min_length=8, max_length=100)
name: Optional[str] = Field(None, max_length=100)
# Yield referral tracking
ref: Optional[str] = Field(None, max_length=100, description="Referral code from yield domain")
class UserLogin(BaseModel):
"""Schema for user login."""
email: EmailStr
password: str
class UserResponse(BaseModel):
"""Schema for user response."""
id: int
email: str
name: Optional[str]
is_active: bool
is_verified: bool
is_admin: bool = False
created_at: datetime
class Config:
from_attributes = True
class Token(BaseModel):
"""Schema for JWT token response."""
access_token: str
token_type: str = "bearer"
expires_in: int
class LoginResponse(BaseModel):
"""Login response when using HttpOnly cookie authentication."""
expires_in: int
class TokenData(BaseModel):
"""Schema for token payload data."""
user_id: Optional[int] = None
email: Optional[str] = None
class ReferralStats(BaseModel):
"""Referral reward snapshot for the current user (3C.2)."""
window_days: int = 30
referred_users_total: int = 0
qualified_referrals_total: int = 0
referral_link_views_window: int = 0
bonus_domains: int = 0
next_reward_at: int = 0
badge: Optional[str] = None # "verified_referrer" | "elite_referrer"
cooldown_days: int = 7
disqualified_cooldown_total: int = 0
disqualified_missing_ip_total: int = 0
disqualified_shared_ip_total: int = 0
disqualified_duplicate_ip_total: int = 0
class ReferralLinkResponse(BaseModel):
invite_code: str
url: str
stats: ReferralStats