Update code in endpoints/api/v1/endpoint.post.py
This commit is contained in:
parent
3407dd7dd0
commit
279560220d
30
endpoints/api/v1/endpoint.post.py
Normal file
30
endpoints/api/v1/endpoint.post.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
|
from core.database import fake_users_db
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
|
@router.post("/login")
|
||||||
|
async def login(
|
||||||
|
username: str,
|
||||||
|
password: str
|
||||||
|
):
|
||||||
|
"""User login endpoint"""
|
||||||
|
user = fake_users_db.get(username)
|
||||||
|
if not user or user["password"] != password:
|
||||||
|
raise HTTPException(status_code=400, detail="Invalid username or password")
|
||||||
|
|
||||||
|
return {
|
||||||
|
"message": "Login successful",
|
||||||
|
"user_id": user["id"],
|
||||||
|
"username": username,
|
||||||
|
"token": f"demo_token_{username}",
|
||||||
|
"features": {
|
||||||
|
"rate_limit": 100,
|
||||||
|
"expires_in": 3600,
|
||||||
|
"permissions": ["read", "write"]
|
||||||
|
},
|
||||||
|
"metadata": {
|
||||||
|
"last_login": "2024-01-01T00:00:00Z",
|
||||||
|
"session_type": "demo"
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user