distro-tools/apollo/server/routes/logout.py
2023-02-01 22:37:16 +01:00

17 lines
466 B
Python

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)