Update code in endpoints/logout.post.py

This commit is contained in:
Backend IM Bot 2025-03-28 10:47:17 +01:00
parent e44deb0ce7
commit 7cec306853

View File

@ -1,17 +1,15 @@
# Entity: User # Entity: User
from fastapi import APIRouter, Depends, status from fastapi import APIRouter, Depends, status
from sqlalchemy.orm import Session from fastapi.security import OAuth2PasswordBearer
from core.database import get_db
from models.user import User from models.user import User
from schemas.user import UserSchema from schemas.user import UserSchema
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=status.HTTP_200_OK)
async def logout( async def logout(token: str = Depends(oauth2_scheme)):
db: Session = Depends(get_db) # Implement logout logic here
): # For example, invalidate the token or remove it from the cache
logout_user(db) return {"message": "Logout successful"}
return {"message": "Logged out successfully"}