26 lines
696 B
Python
26 lines
696 B
Python
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"
|
|
}
|
|
} |