
- Set up SQLite database configuration and directory structure - Configure Alembic for proper SQLite migrations - Add initial model schemas and API endpoints - Fix OAuth2 authentication - Implement proper code formatting with Ruff
44 lines
1.0 KiB
Python
44 lines
1.0 KiB
Python
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, EmailStr, Field
|
|
|
|
|
|
class UserBase(BaseModel):
|
|
"""Base schema for user information."""
|
|
email: EmailStr
|
|
username: str
|
|
is_active: Optional[bool] = True
|
|
|
|
|
|
class UserCreate(UserBase):
|
|
"""Schema for creating a new user."""
|
|
password: str = Field(..., min_length=8)
|
|
|
|
|
|
class UserUpdate(BaseModel):
|
|
"""Schema for updating an existing user."""
|
|
email: Optional[EmailStr] = None
|
|
username: Optional[str] = None
|
|
password: Optional[str] = Field(None, min_length=8)
|
|
is_active: Optional[bool] = None
|
|
|
|
|
|
class UserInDBBase(UserBase):
|
|
"""Base schema for user with DB fields."""
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: Optional[datetime] = None
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class User(UserInDBBase):
|
|
"""Schema for user response data (no password)."""
|
|
pass
|
|
|
|
|
|
class UserInDB(UserInDBBase):
|
|
"""Schema for user in DB (includes password)."""
|
|
hashed_password: str |