EduConnect / app /api /userlogout.py
dtyago's picture
Implemented LLM model and wired it to APIs
10399f1
raw
history blame
No virus
604 Bytes
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)}")