From f4ef5b909b9a12dfd3aa84aa8fa0e058803e878a Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Tue, 23 Feb 2021 23:32:44 +0100 Subject: [PATCH] =?UTF-8?q?Permet=20de=20d=C3=A9sactiver=20la=20connexion?= =?UTF-8?q?=20par=20mot=20de=20passe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- authens/conf.py | 1 + authens/templates/authens/login_switch.html | 2 ++ authens/urls.py | 22 ++++++++++++--------- authens/views.py | 3 +++ 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/authens/conf.py b/authens/conf.py index 94d8cf5..732b984 100644 --- a/authens/conf.py +++ b/authens/conf.py @@ -1,3 +1,4 @@ LDAP_SERVER_URL = "ldaps://ldap.spi.ens.fr:636" AUTHENS_USE_OLDCAS = True +AUTHENS_USE_PASSWORD = True # TODO: CAS_SERVER_URL diff --git a/authens/templates/authens/login_switch.html b/authens/templates/authens/login_switch.html index 3d05908..5e91f71 100644 --- a/authens/templates/authens/login_switch.html +++ b/authens/templates/authens/login_switch.html @@ -10,9 +10,11 @@ {% trans "Clipper" %} + {% if password %} {% trans "Mot de passe" %} + {% endif %} {% if oldcas %} {% trans "Vieilleux" %} diff --git a/authens/urls.py b/authens/urls.py index 18e2aee..2c3e8e6 100644 --- a/authens/urls.py +++ b/authens/urls.py @@ -7,17 +7,21 @@ app_name = "authens" urlpatterns = [ path("login/choose", views.LoginSwitchView.as_view(), name="login"), path("login/cas", views.CASLoginView.as_view(), name="login.cas"), - path("login/pwd", views.PasswordLoginView.as_view(), name="login.pwd"), path("logout", views.LogoutView.as_view(), name="logout"), - path("reset/pwd", views.PasswordResetView.as_view(), name="reset.pwd"), - path( - "reset/pwd///", - views.PasswordResetConfirmView.as_view(), - name="reset.pwd.confirm", - ), ] +if getattr(settings, "AUTHENS_USE_PASSWORD", default_conf.AUTHENS_USE_PASSWORD): + urlpatterns += [ + path("login/pwd", views.PasswordLoginView.as_view(), name="login.pwd"), + path("reset/pwd", views.PasswordResetView.as_view(), name="reset.pwd"), + path( + "reset/pwd///", + views.PasswordResetConfirmView.as_view(), + name="reset.pwd.confirm", + ), + ] + if getattr(settings, "AUTHENS_USE_OLDCAS", default_conf.AUTHENS_USE_OLDCAS): - urlpatterns += ( + urlpatterns += [ path("login/oldcas", views.OldCASLoginView.as_view(), name="login.oldcas"), - ) + ] diff --git a/authens/views.py b/authens/views.py index bcdc702..a1e47da 100644 --- a/authens/views.py +++ b/authens/views.py @@ -55,6 +55,9 @@ class LoginSwitchView(NextPageMixin, TemplateView): "oldcas": getattr( settings, "AUTHENS_USE_OLDCAS", default_conf.AUTHENS_USE_OLDCAS ), + "password": getattr( + settings, "AUTHENS_USE_PASSWORD", default_conf.AUTHENS_USE_PASSWORD + ), } ) return ctx