From 4644c405a616bbe1a6e51c57c034ba82511b3f99 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 26 Jan 2022 15:01:47 +0100 Subject: [PATCH 3/6] auth_fc: make autorun go directly to FranceConnect URL (#61125) --- src/authentic2_auth_fc/authenticators.py | 5 +++-- tests/auth_fc/test_auth_fc.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/authentic2_auth_fc/authenticators.py b/src/authentic2_auth_fc/authenticators.py index 4a159a4c..927e34f0 100644 --- a/src/authentic2_auth_fc/authenticators.py +++ b/src/authentic2_auth_fc/authenticators.py @@ -21,7 +21,6 @@ from django.utils.translation import gettext_noop from authentic2 import app_settings as a2_app_settings from authentic2.authenticators import BaseAuthenticator from authentic2.utils import misc as utils_misc -from authentic2.utils.misc import redirect_to_login from . import app_settings @@ -41,7 +40,9 @@ class FcAuthenticator(BaseAuthenticator): return 'fc' def autorun(self, request, block_id): - return redirect_to_login(request, login_url='fc-login-or-link') + from . import views + + return views.LoginOrLinkView.as_view(display_message_on_redirect=True)(request) def login(self, request, *args, **kwargs): if 'nofc' in request.GET: diff --git a/tests/auth_fc/test_auth_fc.py b/tests/auth_fc/test_auth_fc.py index 64719b00..6d318ebe 100644 --- a/tests/auth_fc/test_auth_fc.py +++ b/tests/auth_fc/test_auth_fc.py @@ -78,7 +78,7 @@ def test_login_autorun(settings, app, franceconnect): # hide password block settings.AUTH_FRONTENDS_KWARGS = {'password': {'show_condition': 'remote_addr==\'0.0.0.0\''}} response = app.get('/login/') - assert response.location == reverse('fc-login-or-link') + assert response.location.startswith('https://fcp') def test_login_username_autofocus(settings, app, franceconnect): -- 2.34.1