from fastapi import APIRouter, Depends, HTTPException from ..utils.db import tinydb_helper # Ensure this import is correct based on our project structure from ..dependencies import oauth2_scheme router = APIRouter() @router.post("/user/logout") async def user_logout(token: str = Depends(oauth2_scheme)): try: # Invalidate the token by removing it from the database tinydb_helper.remove_token_by_value(token) return {"message": "User logged out successfully"} except Exception as e: raise HTTPException(status_code=400, detail=f"Error during logout: {str(e)}")