Update code in endpoints/api/v1/endpoint.post.py
This commit is contained in:
parent
d5d02b294a
commit
7267dbbcc4
33
endpoints/api/v1/endpoint.post.py
Normal file
33
endpoints/api/v1/endpoint.post.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
|
from core.database import fake_users_db
|
||||||
|
from core.auth import get_current_user_dummy
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
|
@router.post("/login")
|
||||||
|
async def login(
|
||||||
|
username: str,
|
||||||
|
password: str
|
||||||
|
):
|
||||||
|
"""Authenticate user and return access token"""
|
||||||
|
user = fake_users_db.get(username)
|
||||||
|
if not user or user["password"] != password:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=400,
|
||||||
|
detail="Incorrect username or password"
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"message": "Login successful",
|
||||||
|
"user": {
|
||||||
|
"username": username,
|
||||||
|
"id": user["id"],
|
||||||
|
"email": user["email"]
|
||||||
|
},
|
||||||
|
"token": "dummy_jwt_token_" + username,
|
||||||
|
"features": {
|
||||||
|
"rate_limit": 100,
|
||||||
|
"expires_in": 3600,
|
||||||
|
"permissions": ["read", "write"]
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user