pellersr-u2i23h/endpoints/logout.post.py
2025-03-28 10:44:39 +01:00

19 lines
546 B
Python

# Entity: User
from fastapi import APIRouter, Depends, status
from fastapi.security import OAuth2PasswordBearer
from sqlalchemy.orm import Session
from core.database import get_db
from schemas.user import UserToken
from helpers.user_helpers import logout_user
router = APIRouter()
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
@router.post("/logout", status_code=200)
async def logout(
token: str = Depends(oauth2_scheme),
db: Session = Depends(get_db)
):
logout_user(token, db)
return {"message": "Logout successful"}