Update code in endpoints/logout.post.py

This commit is contained in:
Backend IM Bot 2025-03-21 17:02:49 +01:00
parent 19901ea6b5
commit c6c867cdc2

View File

@ -9,16 +9,15 @@ async def logout_handler(
db: Session = Depends(get_db)
):
"""Demo logout endpoint"""
user = get_user_from_token(token, db)
user = get_user_from_token(token, fake_users_db)
if not user:
raise HTTPException(status_code=401, detail="Invalid authentication credentials")
# Invalidate token or remove user session
invalidate_token(token)
# Invalidate token or update user session
revoke_token(token)
user["active_session"] = None
return {
"message": "Logout successful",
"next_steps": [
"Redirect to login page"
]
"user_id": user["id"]
}