Spaces:
Runtime error
Runtime error
| from fastapi import APIRouter, Depends, HTTPException | |
| from ..utils.db import tinydb_helper # Ensure this import is correct based on your project structure | |
| from ..dependencies import oauth2_scheme | |
| router = APIRouter() | |
| 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)}") | |