Update code in endpoints/login.post.py
This commit is contained in:
parent
01a8f8e0f4
commit
d66478233b
@ -5,17 +5,19 @@ users = [] # In-memory storage
|
|||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@router.post("/login")
|
@router.post("/login")
|
||||||
async def get_username(
|
async def login_phone(
|
||||||
username: str = "demo"
|
phone: str = "+1234567890",
|
||||||
|
code: str = "123456"
|
||||||
):
|
):
|
||||||
"""Get username endpoint"""
|
"""Phone login endpoint"""
|
||||||
user = next((u for u in users if u["username"] == username), None)
|
user = next((u for u in users if u["phone"] == phone), None)
|
||||||
if not user:
|
if not user or user["code"] != code:
|
||||||
raise HTTPException(status_code=400, detail="Username not found")
|
raise HTTPException(status_code=400, detail="Invalid credentials")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"message": "Username retrieved",
|
"message": "Login successful",
|
||||||
"user": username,
|
"user": phone,
|
||||||
|
"token": "dummy_jwt_token_123",
|
||||||
"features": {
|
"features": {
|
||||||
"rate_limit": 100,
|
"rate_limit": 100,
|
||||||
"expires_in": 3600
|
"expires_in": 3600
|
||||||
|
Loading…
x
Reference in New Issue
Block a user