33 lines
792 B
Python
33 lines
792 B
Python
from fastapi import APIRouter, HTTPException
|
|
import uuid
|
|
|
|
codes = [] # In-memory storage
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post("/login")
|
|
async def generate_auth_code(
|
|
username: str = "demo",
|
|
email: str = "user@example.com"
|
|
):
|
|
"""Generate authentication code endpoint"""
|
|
if not username or not email:
|
|
raise HTTPException(status_code=400, detail="Missing required fields")
|
|
|
|
auth_code = str(uuid.uuid4())
|
|
codes.append({
|
|
"code": auth_code,
|
|
"username": username,
|
|
"email": email,
|
|
"used": False
|
|
})
|
|
|
|
return {
|
|
"message": "Authentication code generated",
|
|
"auth_code": auth_code,
|
|
"username": username,
|
|
"features": {
|
|
"expires_in": 300,
|
|
"max_attempts": 3
|
|
}
|
|
} |