Automated Action 50b3fc513b Implement FastAPI user authentication service with MongoDB
- Set up FastAPI application with MongoDB Motor driver
- Implemented user registration, login, and logout with HTTP-only cookies
- Added JWT token authentication and password hashing
- Created user management endpoints for username updates and password changes
- Structured application with proper separation of concerns (models, schemas, services, routes)
- Added CORS configuration and health endpoints
- Documented API endpoints and environment variables in README
2025-06-20 14:19:13 +00:00

30 lines
655 B
Python

from pydantic import BaseModel, EmailStr, Field
from typing import Optional
from datetime import datetime
class UserCreate(BaseModel):
email: EmailStr
username: str
password: str = Field(..., min_length=8)
class UserLogin(BaseModel):
email: EmailStr
password: str
class UserResponse(BaseModel):
id: str
email: EmailStr
username: str
is_active: bool
created_at: datetime
updated_at: datetime
class UserUpdate(BaseModel):
username: Optional[str] = None
class PasswordChange(BaseModel):
current_password: str
new_password: str = Field(..., min_length=8)
class Message(BaseModel):
message: str