"""Authentication request/response schemas (see ``api.v1.auth``).""" from pydantic import BaseModel, Field class RegisterIn(BaseModel): """Payload of ``POST /api/v1/auth/register``. Usernames are restricted to 3-20 characters of letters, numbers and underscores; passwords must be at least 8 characters. """ username: str = Field( min_length=3, max_length=20, pattern=r"^[a-zA-Z0-9_]{3,20}$", description="3-20 characters: letters, numbers, underscores.", ) password: str = Field(min_length=8, max_length=200) class LoginIn(BaseModel): """Payload of ``POST /api/v1/auth/login``.""" username: str = Field(min_length=1, max_length=60) password: str = Field(min_length=1, max_length=200) class TokenOut(BaseModel): """Token response shared by the register and login endpoints.""" token: str username: str #: Whether the account may access the admin area (see M6). is_admin: bool = False class UserOut(BaseModel): """Payload of ``GET /api/v1/auth/me``.""" username: str #: Whether the account may access the admin area (see M6). is_admin: bool = False