Update code in endpoints/login.post.py

This commit is contained in:
Backend IM Bot 2025-03-22 13:39:46 +00:00
parent c1192ed248
commit fa1a7fd82a

View File

@ -1,25 +1,33 @@
from fastapi import APIRouter, Depends, HTTPException
from fastapi import APIRouter, HTTPException
import uuid
users = [] # In-memory storage
codes = [] # In-memory storage
router = APIRouter()
@router.post("/login")
async def login(
username: str = "user",
password: str = "password"
async def generate_auth_code(
username: str = "demo",
email: str = "user@example.com"
):
"""Login endpoint"""
user = next((u for u in users if u["username"] == username), None)
if not user or user["password"] != password:
raise HTTPException(status_code=400, detail="Invalid credentials")
"""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": "Login successful",
"user": username,
"token": "dummy_jwt_token_123",
"message": "Authentication code generated",
"auth_code": auth_code,
"username": username,
"features": {
"rate_limit": 100,
"expires_in": 3600
"expires_in": 300,
"max_attempts": 3
}
}