Files
mapmaker/app/schemas/user.py

40 lines
925 B
Python

from pydantic import BaseModel, EmailStr, ConfigDict
from typing import Optional
from datetime import datetime
from uuid import UUID
class UserBase(BaseModel):
"""Base user schema with common attributes."""
username: str
email: EmailStr
class UserCreate(UserBase):
"""Schema for creating a new user."""
password: str
class UserUpdate(BaseModel):
"""Schema for updating user information."""
username: Optional[str] = None
email: Optional[EmailStr] = None
password: Optional[str] = None
class UserResponse(UserBase):
"""Response schema for user data (without sensitive info)."""
id: UUID
is_admin: bool
created_at: datetime
updated_at: datetime
model_config = ConfigDict(from_attributes=True)
class UserWithToken(UserResponse):
"""User response with authentication tokens."""
access_token: str
refresh_token: str
token_type: str = "bearer"