Update code in endpoints/login.post.py
This commit is contained in:
parent
c1192ed248
commit
fa1a7fd82a
@ -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 = APIRouter()
|
||||||
|
|
||||||
@router.post("/login")
|
@router.post("/login")
|
||||||
async def login(
|
async def generate_auth_code(
|
||||||
username: str = "user",
|
username: str = "demo",
|
||||||
password: str = "password"
|
email: str = "user@example.com"
|
||||||
):
|
):
|
||||||
"""Login endpoint"""
|
"""Generate authentication code endpoint"""
|
||||||
user = next((u for u in users if u["username"] == username), None)
|
if not username or not email:
|
||||||
if not user or user["password"] != password:
|
raise HTTPException(status_code=400, detail="Missing required fields")
|
||||||
raise HTTPException(status_code=400, detail="Invalid credentials")
|
|
||||||
|
auth_code = str(uuid.uuid4())
|
||||||
|
codes.append({
|
||||||
|
"code": auth_code,
|
||||||
|
"username": username,
|
||||||
|
"email": email,
|
||||||
|
"used": False
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"message": "Login successful",
|
"message": "Authentication code generated",
|
||||||
"user": username,
|
"auth_code": auth_code,
|
||||||
"token": "dummy_jwt_token_123",
|
"username": username,
|
||||||
"features": {
|
"features": {
|
||||||
"rate_limit": 100,
|
"expires_in": 300,
|
||||||
"expires_in": 3600
|
"max_attempts": 3
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user