Files

65 lines
1.5 KiB
Python

"""Pydantic schemas for authentication endpoints."""
from pydantic import BaseModel, EmailStr, Field
class RegisterRequest(BaseModel):
"""Request body for self-service registration."""
account_name: str = Field(
..., min_length=2, max_length=255, description="Company/account name"
)
full_name: str = Field(
..., min_length=2, max_length=255, description="Admin user's full name"
)
email: EmailStr = Field(..., description="Admin user's email address")
password: str = Field(
..., min_length=8, max_length=128, description="Password (min 8 characters)"
)
class LoginRequest(BaseModel):
"""Request body for login."""
email: EmailStr
password: str
class RefreshRequest(BaseModel):
"""Request body for token refresh."""
refresh_token: str
class UserInfo(BaseModel):
"""Basic user info returned with tokens (no password hash)."""
id: str
email: str
full_name: str
account_id: str
role_id: str | None = None
role_name: str | None = None
permissions: list[str] = []
class TokenResponse(BaseModel):
"""Response with access and refresh tokens, plus user info."""
access_token: str
refresh_token: str
token_type: str = "bearer"
user: UserInfo
class UserResponse(BaseModel):
"""Public user representation (no password hash)."""
id: str
email: str
full_name: str
is_active: bool
role_id: str | None = None
model_config = {"from_attributes": True}