distro-tools/apollo/server/routes/logout.py

17 lines
466 B
Python
Raw Normal View History

2023-02-01 21:37:16 +00:00
from fastapi import APIRouter, Request
from fastapi.responses import RedirectResponse
router = APIRouter(tags=["non-api"])
@router.get("/")
async def logout(request: Request):
if request.session.get("user"):
request.session.pop("user")
if request.session.get("user.name"):
request.session.pop("user.name")
if request.session.get("user.role"):
request.session.pop("user.role")
return RedirectResponse("/", status_code=302)