Update code in endpoints/person.get.py
This commit is contained in:
parent
ebf339b0cb
commit
50ce42aa2d
26
endpoints/person.get.py
Normal file
26
endpoints/person.get.py
Normal file
@ -0,0 +1,26 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from core.database import fake_users_db
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/person")
|
||||
async def person_handler(
|
||||
token: str = Depends(oauth2_scheme),
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""Get current authenticated user"""
|
||||
user = get_current_user(token, db)
|
||||
if not user:
|
||||
raise HTTPException(status_code=401, detail="Invalid authentication credentials")
|
||||
|
||||
return {
|
||||
"message": "User authenticated",
|
||||
"data": {
|
||||
"id": user.id,
|
||||
"username": user.username,
|
||||
"email": user.email
|
||||
},
|
||||
"metadata": {
|
||||
"auth_method": "bearer_token"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user