From cacdd7dc54d4cef0f40e18481d044538939dda4c Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Mon, 24 Mar 2025 09:15:43 +0100 Subject: [PATCH] Update code in endpoints/logout.post.py --- endpoints/logout.post.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/endpoints/logout.post.py b/endpoints/logout.post.py index 1966701..c4e35f4 100644 --- a/endpoints/logout.post.py +++ b/endpoints/logout.post.py @@ -1,13 +1,23 @@ -from fastapi import APIRouter, HTTPException +from fastapi import APIRouter, Depends, HTTPException + +users = [] # In-memory storage router = APIRouter() @router.post("/logout") -async def logout(): - """Logout endpoint""" +async def logout_demo( + username: str = "logged_in_user" +): + """Demo logout endpoint""" if request.method != "POST": raise HTTPException(status_code=405, detail="Method Not Allowed") + user = next((u for u in users if u["username"] == username), None) + if not user: + raise HTTPException(status_code=400, detail="Invalid user") + + # Perform logout logic (e.g., invalidate token) + return { "message": "Logout successful", "method": "POST",