Skip to content

Commit

Permalink
redirection vers les réglementations limitée à la connexion sur /
Browse files Browse the repository at this point in the history
Cela permet d'accéder à la page d'accueil dans le reste de la navigation
  • Loading branch information
sblondon committed Oct 25, 2023
1 parent 0209e19 commit 85928b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions impact/public/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ def test_page_index_pour_un_visiteur_anonyme(client):
assert "<!-- page index -->" in content


def test_redirection_de_la_page_index_vers_ses_reglementations_si_l_utilisateur_est_connecte(
def test_redirection_de_la_page_index_vers_ses_reglementations_si_l_utilisateur_vient_de_se_connecter_depuis_la_page_d_accueil(
client, alice
):
client.force_login(alice)

response = client.get("/", follow=True)
response = client.get(
"/", follow=True, headers={"referer": "http://domain.test/connexion?next=/"}
)

assert response.status_code == 200
assert response.redirect_chain == [
Expand Down
3 changes: 2 additions & 1 deletion impact/public/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@


def index(request):
if request.user.is_authenticated:
referer = request.META.get("HTTP_REFERER", "")
if referer.endswith("/connexion?next=/"):
return redirect(reverse("reglementations"))
return render(request, "public/index.html")

Expand Down

0 comments on commit 85928b5

Please sign in to comment.