Update code in endpoints/logout.post.py
This commit is contained in:
parent
19901ea6b5
commit
c6c867cdc2
@ -9,16 +9,15 @@ async def logout_handler(
|
|||||||
db: Session = Depends(get_db)
|
db: Session = Depends(get_db)
|
||||||
):
|
):
|
||||||
"""Demo logout endpoint"""
|
"""Demo logout endpoint"""
|
||||||
user = get_user_from_token(token, db)
|
user = get_user_from_token(token, fake_users_db)
|
||||||
if not user:
|
if not user:
|
||||||
raise HTTPException(status_code=401, detail="Invalid authentication credentials")
|
raise HTTPException(status_code=401, detail="Invalid authentication credentials")
|
||||||
|
|
||||||
# Invalidate token or remove user session
|
# Invalidate token or update user session
|
||||||
invalidate_token(token)
|
revoke_token(token)
|
||||||
|
user["active_session"] = None
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"message": "Logout successful",
|
"message": "Logout successful",
|
||||||
"next_steps": [
|
"user_id": user["id"]
|
||||||
"Redirect to login page"
|
|
||||||
]
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user