Update code in endpoints/api/v1/endpoint.post.py
This commit is contained in:
parent
c52cd89752
commit
665292674e
32
endpoints/api/v1/endpoint.post.py
Normal file
32
endpoints/api/v1/endpoint.post.py
Normal file
@ -0,0 +1,32 @@
|
||||
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("/endpoint")
|
||||
async def fetch_user_details(
|
||||
username: str = "demo",
|
||||
token: str = Depends(get_current_user_dummy)
|
||||
):
|
||||
"""Fetch user details endpoint"""
|
||||
user = fake_users_db.get(username)
|
||||
if not user:
|
||||
raise HTTPException(status_code=404, detail="User not found")
|
||||
|
||||
# Remove sensitive information
|
||||
user_data = {
|
||||
"id": user["id"],
|
||||
"username": username,
|
||||
"email": user["email"],
|
||||
"disabled": user["disabled"]
|
||||
}
|
||||
|
||||
return {
|
||||
"message": "User details retrieved successfully",
|
||||
"user": user_data,
|
||||
"metadata": {
|
||||
"timestamp": "2024-01-01T00:00:00Z",
|
||||
"source": "demo_db"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user