From 2044314088d5414a837515b5c5783338164b63be Mon Sep 17 00:00:00 2001 From: vincent porte Date: Thu, 14 Nov 2024 00:19:35 +0100 Subject: [PATCH] updates routes to manage login-logout --- lacommunaute/openid_connect/tests/tests_views.py | 2 +- .../pages/tests/__snapshots__/test_homepage.ambr | 16 ++++++++-------- lacommunaute/surveys/tests/test_views.py | 2 +- lacommunaute/templates/partials/header.html | 16 ++++------------ .../registration/includes/login_link.html | 2 ++ .../registration/includes/logout_link.html | 6 ++++++ lacommunaute/templates/surveys/dsp_form.html | 4 +--- 7 files changed, 23 insertions(+), 25 deletions(-) create mode 100644 lacommunaute/templates/registration/includes/login_link.html create mode 100644 lacommunaute/templates/registration/includes/logout_link.html diff --git a/lacommunaute/openid_connect/tests/tests_views.py b/lacommunaute/openid_connect/tests/tests_views.py index 63b7fd38e..746f0f795 100644 --- a/lacommunaute/openid_connect/tests/tests_views.py +++ b/lacommunaute/openid_connect/tests/tests_views.py @@ -179,7 +179,7 @@ def test_normal_signin(self): # Then log in again. response = self.client.get(reverse("pages:home")) - self.assertContains(response, reverse("openid_connect:authorize")) + self.assertContains(response, reverse("users:login")) response = mock_oauth_dance(self, assert_redirects=False) expected_redirection = reverse("pages:home") diff --git a/lacommunaute/pages/tests/__snapshots__/test_homepage.ambr b/lacommunaute/pages/tests/__snapshots__/test_homepage.ambr index 37894f351..3d7864583 100644 --- a/lacommunaute/pages/tests/__snapshots__/test_homepage.ambr +++ b/lacommunaute/pages/tests/__snapshots__/test_homepage.ambr @@ -164,11 +164,11 @@ - +
  • - Se connecter | S'inscrire -
  • - + Se connecter | S'inscrire + + @@ -255,11 +255,11 @@ + diff --git a/lacommunaute/surveys/tests/test_views.py b/lacommunaute/surveys/tests/test_views.py index a974223f0..d37e0676a 100644 --- a/lacommunaute/surveys/tests/test_views.py +++ b/lacommunaute/surveys/tests/test_views.py @@ -23,7 +23,7 @@ location_field_list = ["location", "city_code"] form_html = '
    ' -login_with_next_url = reverse("openid_connect:authorize") + "?next=" + reverse("surveys:dsp_create") +login_with_next_url = reverse("users:login") + "?next=" + reverse("surveys:dsp_create") class TestDSPCreateView: diff --git a/lacommunaute/templates/partials/header.html b/lacommunaute/templates/partials/header.html index 8a7f70065..849bf078c 100644 --- a/lacommunaute/templates/partials/header.html +++ b/lacommunaute/templates/partials/header.html @@ -103,16 +103,12 @@
  • -
  • - Déconnexion -
  • +
  • {% include "registration/includes/logout_link.html" %}
  • {% else %} -
  • - Se connecter | S'inscrire -
  • +
  • {% include "registration/includes/login_link.html" %}
  • {% endif %} @@ -277,16 +273,12 @@

  • -
  • - Déconnexion -
  • +
  • {% include "registration/includes/logout_link.html" %}
  • {% else %} -
    - Se connecter | S'inscrire -
    +
    {% include "registration/includes/login_link.html" %}
    {% endif %} diff --git a/lacommunaute/templates/registration/includes/login_link.html b/lacommunaute/templates/registration/includes/login_link.html new file mode 100644 index 000000000..c293b6920 --- /dev/null +++ b/lacommunaute/templates/registration/includes/login_link.html @@ -0,0 +1,2 @@ +{% load i18n %} +{% trans "Login | Sign in" %} diff --git a/lacommunaute/templates/registration/includes/logout_link.html b/lacommunaute/templates/registration/includes/logout_link.html new file mode 100644 index 000000000..ef233f9f1 --- /dev/null +++ b/lacommunaute/templates/registration/includes/logout_link.html @@ -0,0 +1,6 @@ +{% if request.session.MAGIC_LINK %} + {% url 'users:logout' as logout_url %} +{% else %} + {% url 'openid_connect:logout' as logout_url %} +{% endif %} +Déconnexion diff --git a/lacommunaute/templates/surveys/dsp_form.html b/lacommunaute/templates/surveys/dsp_form.html index 8add61e34..6a85a83a9 100644 --- a/lacommunaute/templates/surveys/dsp_form.html +++ b/lacommunaute/templates/surveys/dsp_form.html @@ -66,9 +66,7 @@

    Diagnostic Parcours IAE

    Je me connecte pour accéder à l'aide au diagnostic pour le parcours IAE
    - +
    {% include "registration/includes/login_link.html" %}