from fastapi import APIRouter, Depends, HTTPException from core.database import fake_users_db import uuid router = APIRouter() @router.post("/login") async def login_handler( username: str = "demo", password: str = "password" ): """Add predefined users and authenticate""" # Add predefined users if they don't exist if "Chidi" not in fake_users_db: fake_users_db["Chidi"] = { "id": str(uuid.uuid4()), "email": "chidi@example.com", "password": "chidi_password", "disabled": False } if "Nneoma" not in fake_users_db: fake_users_db["Nneoma"] = { "id": str(uuid.uuid4()), "email": "nneoma@example.com", "password": "nneoma_password", "disabled": False } user = fake_users_db.get(username) if not user or user["password"] != password: raise HTTPException(status_code=400, detail="Invalid credentials") return { "message": "Login successful (demo)", "user": username, "token": "dummy_jwt_token_123", "features": { "rate_limit": 100, "expires_in": 3600 }, "available_users": ["Chidi", "Nneoma"] }