Automated Action 8fefbb7c13 Add user authentication to the Todo app
- Created User model and schemas
- Implemented secure password hashing with bcrypt
- Added JWT token-based authentication
- Created user registration and login endpoints
- Added authentication to todo routes
- Updated todos to be associated with users
- Created migration script for the user table
- Updated documentation with auth information
2025-05-19 13:45:22 +00:00

45 lines
885 B
Python

from datetime import datetime
from typing import Optional
from pydantic import BaseModel
class TodoBase(BaseModel):
"""Base schema for Todo items"""
title: str
description: Optional[str] = None
completed: bool = False
class TodoCreate(TodoBase):
"""Schema for creating a new Todo item"""
# No need to include owner_id here as it will be set from the current user
class TodoUpdate(BaseModel):
"""Schema for updating a Todo item"""
title: Optional[str] = None
description: Optional[str] = None
completed: Optional[bool] = None
class TodoInDBBase(TodoBase):
"""Base schema for Todo items from the database"""
id: int
owner_id: int
created_at: datetime
updated_at: datetime
class Config:
from_attributes = True
class Todo(TodoInDBBase):
"""Schema for Todo items returned from the API"""
pass