Update code in endpoints/logout.post.py
This commit is contained in:
parent
531bd176f2
commit
cacdd7dc54
@ -1,13 +1,23 @@
|
|||||||
from fastapi import APIRouter, HTTPException
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
|
|
||||||
|
users = [] # In-memory storage
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@router.post("/logout")
|
@router.post("/logout")
|
||||||
async def logout():
|
async def logout_demo(
|
||||||
"""Logout endpoint"""
|
username: str = "logged_in_user"
|
||||||
|
):
|
||||||
|
"""Demo logout endpoint"""
|
||||||
if request.method != "POST":
|
if request.method != "POST":
|
||||||
raise HTTPException(status_code=405, detail="Method Not Allowed")
|
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 {
|
return {
|
||||||
"message": "Logout successful",
|
"message": "Logout successful",
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user