fix: redirect to landing page after logout instead of login page

This commit is contained in:
Oliver Hofmann 2026-04-27 14:04:03 +02:00
parent f3781b0de1
commit 3832b81174
2 changed files with 3 additions and 2 deletions

View File

@ -47,7 +47,7 @@ async def login(
@router.get("/logout")
async def logout():
response = RedirectResponse(url="/auth/login", status_code=303)
response = RedirectResponse(url="/", status_code=303)
clear_auth_cookie(response)
return response

View File

@ -65,8 +65,9 @@ def test_login_unknown_user_shows_error(client):
assert "Ungültige" in response.text
def test_logout_clears_cookie(client, alice):
def test_logout_clears_cookie_and_redirects_to_landing(client, alice):
client.post("/auth/login", data={"username": "alice", "password": "secret123"})
response = client.get("/auth/logout")
assert response.status_code in (302, 303, 307)
assert response.headers["location"] == "/"
assert response.cookies.get("access_token", "") == ""