Automated Action b7392c9694 Add user authentication flow with FastAPI
- Set up FastAPI project structure with main.py and requirements.txt
- Create User model with SQLAlchemy and SQLite database
- Implement JWT token-based authentication system
- Add password hashing with bcrypt
- Create auth endpoints: register, login, and protected /me route
- Set up Alembic for database migrations
- Add health check endpoint with database status
- Configure CORS to allow all origins
- Update README with setup instructions and environment variables
2025-06-20 10:53:35 +00:00

29 lines
560 B
Python

from pydantic import BaseModel, EmailStr
from datetime import datetime
from typing import Optional
class UserBase(BaseModel):
email: EmailStr
class UserCreate(UserBase):
password: str
class UserLogin(BaseModel):
email: EmailStr
password: str
class User(UserBase):
id: int
is_active: bool
created_at: datetime
updated_at: Optional[datetime] = None
class Config:
from_attributes = True
class Token(BaseModel):
access_token: str
token_type: str
class TokenData(BaseModel):
email: Optional[str] = None