Skip to content

Commit

Permalink
updates routes to manage login-logout
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Nov 14, 2024
1 parent 03a9b24 commit 2044314
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 25 deletions.
2 changes: 1 addition & 1 deletion lacommunaute/openid_connect/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
16 changes: 8 additions & 8 deletions lacommunaute/pages/tests/__snapshots__/test_homepage.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@
</div>
</form>
</li>

<li>
<a class="btn" href="/pro_connect/authorize" rel="nofollow">Se connecter | S'inscrire</a>
</li>
<a class="btn btn-outline-primary btn-ico btn-block" href="/users/login/?next=/" rel="nofollow">Se connecter | S'inscrire</a>
</li>

</ul>
</nav>
</div>
Expand Down Expand Up @@ -255,11 +255,11 @@
</div>
<div class="offcanvas-footer flex-column align-items-stretch">
<nav aria-label="Menu de navigation principale pour mobile" role="navigation">

<div>
<a class="btn" href="/pro_connect/authorize" rel="nofollow">Se connecter | S'inscrire</a>
</div>
<a class="btn btn-outline-primary btn-ico btn-block" href="/members/login/?next=/" rel="nofollow">Se connecter | S'inscrire</a>
</div>

</nav>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion lacommunaute/surveys/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
location_field_list = ["location", "city_code"]

form_html = '<form method="post">'
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:
Expand Down
16 changes: 4 additions & 12 deletions lacommunaute/templates/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,12 @@
<li>
<div class="dropdown-divider"></div>
</li>
<li>
<a class="dropdown-item text-danger" id="js-logout" href="{% url 'openid_connect:logout' %}">Déconnexion</a>
</li>
<li>{% include "registration/includes/logout_link.html" %}</li>
</ul>
</div>
</li>
{% else %}
<li>
<a href="{% url 'openid_connect:authorize' %}" rel="nofollow" class="btn">Se connecter | S'inscrire</a>
</li>
<li>{% include "registration/includes/login_link.html" %}</li>
{% endif %}
</ul>
</nav>
Expand Down Expand Up @@ -277,16 +273,12 @@ <h4 class="h5 mb-0 btn-ico align-items-center" id="offcanvasApplyFiltersLabel">
<li>
<div class="dropdown-divider"></div>
</li>
<li>
<a class="dropdown-item text-danger" id="js-logout" href="{% url 'openid_connect:logout' %}">Déconnexion</a>
</li>
<li>{% include "registration/includes/logout_link.html" %}</li>
</ul>
</div>
</div>
{% else %}
<div>
<a href="{% url 'openid_connect:authorize' %}" rel="nofollow" class="btn">Se connecter | S'inscrire</a>
</div>
<div>{% include "registration/includes/login_link.html" %}</div>
{% endif %}
</nav>
</div>
Expand Down
2 changes: 2 additions & 0 deletions lacommunaute/templates/registration/includes/login_link.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% load i18n %}
<a href="{% url 'users:login' %}?next={{ request.path }}" rel="nofollow" class="btn btn-outline-primary btn-ico btn-block">{% trans "Login | Sign in" %}</a>
6 changes: 6 additions & 0 deletions lacommunaute/templates/registration/includes/logout_link.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% if request.session.MAGIC_LINK %}
{% url 'users:logout' as logout_url %}
{% else %}
{% url 'openid_connect:logout' as logout_url %}
{% endif %}
<a class="dropdown-item text-danger" id="js-logout" href="{{ logout_url }}"">Déconnexion</a>
4 changes: 1 addition & 3 deletions lacommunaute/templates/surveys/dsp_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ <h1 class="s-title-01__title h1">Diagnostic Parcours IAE</h1>
<div class="c-box mb-5">
<div class="row">
<div class="col-lg col-12 mb-3">Je me connecte pour accéder à l'aide au diagnostic pour le parcours IAE</div>
<div class="col-lg-auto col-12">
<a href="{% url 'openid_connect:authorize' %}?next={% url 'surveys:dsp_create' %}" rel="nofollow" class="btn btn-outline-primary btn-ico btn-block">Me connecter</a>
</div>
<div class="col-lg-auto col-12">{% include "registration/includes/login_link.html" %}</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 2044314

Please sign in to comment.