From 61b8f1f7b9c8d0f7a644b5e1f52ad0bc8870935d Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Thu, 10 Jun 2021 11:07:54 +0200 Subject: [PATCH 1/3] =?UTF-8?q?Permet=20de=20passer=20un=20formulaire=20pe?= =?UTF-8?q?rsonnalis=C3=A9=20pour=20la=20r=C3=A9initialisation=20de=20mdp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- authens/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/authens/views.py b/authens/views.py index a1e47da..110ceaa 100644 --- a/authens/views.py +++ b/authens/views.py @@ -3,6 +3,7 @@ from urllib.parse import urlparse, urlunparse from django.conf import settings from django.contrib import auth from django.contrib.auth import views as auth_views +from django.contrib.auth.forms import PasswordResetForm from django.contrib.messages.views import SuccessMessageMixin from django.core.exceptions import PermissionDenied from django.shortcuts import redirect @@ -101,6 +102,9 @@ class PasswordResetView(SuccessMessageMixin, auth_views.PasswordResetView): subject_template_name = "authens/pwd_reset_subject.txt" success_url = reverse_lazy("authens:login") + def get_form_class(self): + return getattr(settings, "AUTHENS_PWD_RESET_FORM", PasswordResetForm) + success_message = _( "Un email de réinitialisation vient d'être envoyé à l'adresse indiquée !" ) -- 2.47.1 From 97543a56633b32f2de802d21f7a9be0d78c22e3c Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Thu, 10 Jun 2021 11:13:32 +0200 Subject: [PATCH 2/3] Update README --- README.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1c4cc78..0931be2 100644 --- a/README.md +++ b/README.md @@ -47,9 +47,9 @@ en plus du site. ### Dans le fichier `settings.py` -- Ajouter `"authens"` dans les [`INSTALLED_APPS`](https://docs.djangoproject.com/en/3.0/ref/settings/#installed-apps). +- Ajouter `"authens"` dans les [`INSTALLED_APPS`](https://docs.djangoproject.com/en/3.2/ref/settings/#installed-apps). - Ajouter `"authens.backends.ENSCASBackend"` dans les - [`AUTHENTICATION_BACKENDS`](https://docs.djangoproject.com/en/3.0/ref/settings/#authentication-backends). + [`AUTHENTICATION_BACKENDS`](https://docs.djangoproject.com/en/3.2/ref/settings/#authentication-backends). Si `AUTHENTICATION_BACKENDS` n'apparaît pas dans vos settings, utiliser : ```python @@ -85,11 +85,20 @@ AUTHENS_ALLOW_STAFF = True - (Optionnel) AuthENS utilise le paramètre Django standard - [`LOGIN_REDIRECT_URL`](https://docs.djangoproject.com/en/3.0/ref/settings/#login-redirect-url) + [`LOGIN_REDIRECT_URL`](https://docs.djangoproject.com/en/3.2/ref/settings/#login-redirect-url) par défaut pour rediriger l'utilisateurice en cas de connexion réussie. Il peut être utile de définir ce paramètre. +- (Optionnel) Pour filtrer quels utilisateurs peuvent réinitialiser leur mot de + passe, il est possible de définir un formulaire personnalisé pour remplacer le + formulaire Django standard [`PasswordResetForm`](https://docs.djangoproject.com/en/3.2/topics/auth/default/#django.contrib.auth.forms.PasswordResetForm) + +```python +AUTHENS_PASSWORD_RESET_FORM = CustomPwdResetForm +``` + + ## Utilisation À lire @@ -144,7 +153,7 @@ celui-ci. Les templates à substituer sont : ### Migration depuis `django_cas_ng` Pour migrer depuis `django_cas_ng`, il est recommandé de faire une -[data migration](https://docs.djangoproject.com/en/3.1/howto/writing-migrations/#migrating-data-between-third-party-apps) +[data migration](https://docs.djangoproject.com/en/3.2/howto/writing-migrations/#migrating-data-between-third-party-apps) et d'appliquer la fonction `register_cas_account` sur tou⋅tes les utilisateurices. -- 2.47.1 From 1eda6c65c273cec92a94b1c4760f9ee76f5cdd14 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Thu, 10 Jun 2021 11:15:59 +0200 Subject: [PATCH 3/3] Consistency --- authens/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/authens/views.py b/authens/views.py index 110ceaa..36179a8 100644 --- a/authens/views.py +++ b/authens/views.py @@ -103,7 +103,7 @@ class PasswordResetView(SuccessMessageMixin, auth_views.PasswordResetView): success_url = reverse_lazy("authens:login") def get_form_class(self): - return getattr(settings, "AUTHENS_PWD_RESET_FORM", PasswordResetForm) + return getattr(settings, "AUTHENS_PASSWORD_RESET_FORM", PasswordResetForm) success_message = _( "Un email de réinitialisation vient d'être envoyé à l'adresse indiquée !" -- 2.47.1