Update code in endpoints/logout.post.py

This commit is contained in:
Backend IM Bot 2025-03-28 10:45:14 +01:00
parent 28098d5be5
commit e44deb0ce7

View File

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