From de1d0973413843251bde6d856d253caf824a50e6 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Fri, 28 Mar 2025 10:47:33 +0100 Subject: [PATCH] Update code in endpoints/logout.post.py --- endpoints/logout.post.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/endpoints/logout.post.py b/endpoints/logout.post.py index ec4a124..150fa0b 100644 --- a/endpoints/logout.post.py +++ b/endpoints/logout.post.py @@ -1,15 +1,17 @@ # Entity: User -from fastapi import APIRouter, Depends, status -from fastapi.security import OAuth2PasswordBearer +from fastapi import APIRouter, Depends, HTTPException, status +from sqlalchemy.orm import Session +from core.database import get_db from models.user import User from schemas.user import UserSchema +from helpers.user_helpers import logout_user router = APIRouter() -oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") -@router.post("/logout", status_code=status.HTTP_200_OK) -async def logout(token: str = Depends(oauth2_scheme)): - # Implement logout logic here - # For example, invalidate the token or remove it from the cache - return {"message": "Logout successful"} \ No newline at end of file +@router.post("/logout", status_code=200) +async def logout( + db: Session = Depends(get_db) +): + logout_user(db) + return {"message": "Logged out successfully"} \ No newline at end of file