Backend for pwd reset views
This commit is contained in:
parent
fb06e2005c
commit
5f5edb4935
3 changed files with 36 additions and 2 deletions
|
@ -9,4 +9,10 @@ urlpatterns = [
|
||||||
path("login/pwd", views.PasswordLoginView.as_view(), name="login.pwd"),
|
path("login/pwd", views.PasswordLoginView.as_view(), name="login.pwd"),
|
||||||
path("login/oldcas", views.OldCASLoginView.as_view(), name="login.oldcas"),
|
path("login/oldcas", views.OldCASLoginView.as_view(), name="login.oldcas"),
|
||||||
path("logout", views.LogoutView.as_view(), name="logout"),
|
path("logout", views.LogoutView.as_view(), name="logout"),
|
||||||
|
path("reset/pwd", views.PasswordResetView.as_view(), name="reset.pwd"),
|
||||||
|
path(
|
||||||
|
"reset/pwd/<uidb64>/<token>/",
|
||||||
|
views.PasswordResetConfirmView.as_view(),
|
||||||
|
name="reset.pwd.confirm",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -3,13 +3,16 @@ from urllib.parse import urlparse, urlunparse
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import auth
|
from django.contrib import auth
|
||||||
from django.contrib.auth import views as auth_views
|
from django.contrib.auth import views as auth_views
|
||||||
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.views.generic import TemplateView, View
|
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django.urls import reverse_lazy
|
||||||
|
from django.views.generic import TemplateView, View
|
||||||
|
|
||||||
from authens.utils import get_cas_client
|
|
||||||
from authens.forms import OldCASAuthForm
|
from authens.forms import OldCASAuthForm
|
||||||
|
from authens.utils import get_cas_client
|
||||||
|
|
||||||
|
|
||||||
class NextPageMixin:
|
class NextPageMixin:
|
||||||
|
@ -80,10 +83,33 @@ class PasswordLoginView(auth_views.LoginView):
|
||||||
template_name = "authens/pwd_login.html"
|
template_name = "authens/pwd_login.html"
|
||||||
|
|
||||||
|
|
||||||
|
class PasswordResetView(SuccessMessageMixin, auth_views.PasswordResetView):
|
||||||
|
template_name = "authens/pwd_reset.html"
|
||||||
|
email_template_name = "authens/pwd_reset_email.txt"
|
||||||
|
subject_template_name = "authens/pwd_reset_subject.txt"
|
||||||
|
success_url = reverse_lazy("authens:login")
|
||||||
|
|
||||||
|
success_message = _(
|
||||||
|
"Un email de réinitialisation vient d'être envoyé à l'adresse indiquée !"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class PasswordResetConfirmView(
|
||||||
|
SuccessMessageMixin, auth_views.PasswordResetConfirmView
|
||||||
|
):
|
||||||
|
template_name = "authens/pwd_reset_confirm.html"
|
||||||
|
success_url = reverse_lazy("authens:login")
|
||||||
|
|
||||||
|
success_message = _("Mot de passe modifié avec succès !")
|
||||||
|
|
||||||
|
|
||||||
class OldCASLoginView(auth_views.LoginView):
|
class OldCASLoginView(auth_views.LoginView):
|
||||||
template_name = "authens/old_cas_login.html"
|
template_name = "authens/old_cas_login.html"
|
||||||
authentication_form = OldCASAuthForm
|
authentication_form = OldCASAuthForm
|
||||||
|
|
||||||
|
def get_initial(self):
|
||||||
|
return {"entrance_year": timezone.now().year - 5}
|
||||||
|
|
||||||
|
|
||||||
class LogoutView(auth_views.LogoutView):
|
class LogoutView(auth_views.LogoutView):
|
||||||
"""Logout view of AuthENS.
|
"""Logout view of AuthENS.
|
||||||
|
|
|
@ -128,6 +128,8 @@ AUTHENTICATION_BACKENDS = [
|
||||||
"authens.backends.OldCASBackend",
|
"authens.backends.OldCASBackend",
|
||||||
]
|
]
|
||||||
LOGIN_URL = reverse_lazy("authens:login")
|
LOGIN_URL = reverse_lazy("authens:login")
|
||||||
|
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||||
|
|
||||||
|
|
||||||
# This is cosmetic
|
# This is cosmetic
|
||||||
LOGIN_REDIRECT_URL = reverse_lazy("home")
|
LOGIN_REDIRECT_URL = reverse_lazy("home")
|
||||||
|
|
Loading…
Reference in a new issue