diff --git a/app/modules/auth/router.py b/app/modules/auth/router.py index 6a922c0..c91f99b 100644 --- a/app/modules/auth/router.py +++ b/app/modules/auth/router.py @@ -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 diff --git a/tests/test_auth_router.py b/tests/test_auth_router.py index 519e9fb..4080665 100644 --- a/tests/test_auth_router.py +++ b/tests/test_auth_router.py @@ -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", "") == ""