Update code in endpoints/me.post.py
This commit is contained in:
parent
7061c2f5ae
commit
082c4dcfa9
23
endpoints/me.post.py
Normal file
23
endpoints/me.post.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
|
from core.database import fake_users_db
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
|
@router.post("/me")
|
||||||
|
async def me_handler(
|
||||||
|
token: str = Depends(oauth2_scheme),
|
||||||
|
db: Session = Depends(get_db)
|
||||||
|
):
|
||||||
|
"""Demo user endpoint"""
|
||||||
|
user = get_user_from_token(token, db)
|
||||||
|
if not user:
|
||||||
|
raise HTTPException(status_code=401, detail="Invalid authentication credentials")
|
||||||
|
|
||||||
|
clear_session(token, db)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"message": "Logout successful",
|
||||||
|
"metadata": {
|
||||||
|
"token": token
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user