Files
root 801e6a050b prod: UI Optimisée mise en production
- Documentation archivée et réorganisée
- Backend: Ajout tests, migrations, library service, rate limiting
- Frontend: Suppression Flutter, focus sur interface web HTML/JS
- Tailwind CSS ajouté pour le style
- Améliorations UX et corrections bugs

Generated with [Claude Code](https://claude.com/claude-code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-01-20 09:56:39 +00:00

86 lines
2.0 KiB
Python

"""Authentication schemas."""
from datetime import datetime
from typing import Optional
from uuid import UUID
from pydantic import BaseModel, EmailStr, Field, ConfigDict, field_validator
class UserBase(BaseModel):
"""Base user schema."""
email: EmailStr
username: str = Field(..., min_length=3, max_length=50)
display_name: Optional[str] = Field(None, max_length=100)
class UserCreate(UserBase):
"""Schema for creating a new user."""
password: str = Field(..., min_length=8, max_length=100)
class UserUpdate(BaseModel):
"""Schema for updating user profile."""
display_name: Optional[str] = Field(None, max_length=100)
avatar_url: Optional[str] = None
date_of_birth: Optional[datetime] = None
country: Optional[str] = Field(None, max_length=2)
class UserResponse(UserBase):
"""Schema for user response."""
model_config = ConfigDict(from_attributes=True)
id: str
display_name: Optional[str] = None
avatar_url: Optional[str] = None
is_premium: bool = False
created_at: datetime
updated_at: datetime
@field_validator('id', mode='before')
@classmethod
def convert_uuid_to_str(cls, v: UUID) -> str:
"""Convert UUID to string for JSON serialization."""
return str(v) if isinstance(v, UUID) else v
class Token(BaseModel):
"""Schema for JWT token response."""
access_token: str
refresh_token: str
token_type: str = "bearer"
expires_in: int # seconds
class TokenPayload(BaseModel):
"""Schema for JWT token payload."""
sub: str # user id
exp: int # expiration timestamp
type: str # "access" or "refresh"
class LoginRequest(BaseModel):
"""Schema for login request."""
email: EmailStr
password: str
class RefreshTokenRequest(BaseModel):
"""Schema for token refresh request."""
refresh_token: str
class ChangePasswordRequest(BaseModel):
"""Schema for password change request."""
old_password: str = Field(..., min_length=8, max_length=100)
new_password: str = Field(..., min_length=8, max_length=100)