Add password change and reset functionality with corresponding views and templates
This commit is contained in:
parent
a24fb897a3
commit
da1c750771
5 changed files with 61 additions and 2 deletions
8
base/templates/registration/password_change_form.html
Normal file
8
base/templates/registration/password_change_form.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
{% extends "base.html" %}
|
||||
{% load form %}
|
||||
{% block content %}
|
||||
<h1>
|
||||
<i class="ri-lock-password-line"></i> Changer mon mot de passe
|
||||
</h1>
|
||||
{% form form submit="Changer mon mot de passe" %}
|
||||
{% endblock content %}
|
8
base/templates/registration/password_reset_confirm.html
Normal file
8
base/templates/registration/password_reset_confirm.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
{% extends "base.html" %}
|
||||
{% load form %}
|
||||
{% block content %}
|
||||
<h1>
|
||||
<i class="ri-lock-password-line"></i> Réinitialiser mon mot de passe
|
||||
</h1>
|
||||
{% form form submit="Réinitialiser mon mot de passe" %}
|
||||
{% endblock content %}
|
8
base/templates/registration/password_reset_form.html
Normal file
8
base/templates/registration/password_reset_form.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
{% extends "base.html" %}
|
||||
{% load form %}
|
||||
{% block content %}
|
||||
<h1>
|
||||
<i class="ri-lock-password-line"></i> Réinitialiser mon mot de passe
|
||||
</h1>
|
||||
{% form form submit="Réinitialiser mon mot de passe" %}
|
||||
{% endblock content %}
|
21
base/urls.py
21
base/urls.py
|
@ -1,4 +1,5 @@
|
|||
from django.urls import include, path
|
||||
from django.contrib.auth import views as auth_views
|
||||
from django.urls import path
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from . import views
|
||||
|
@ -6,6 +7,22 @@ from . import views
|
|||
urlpatterns = [
|
||||
path("", views.HomePageView.as_view(), name="index"),
|
||||
path("accounts/signup/", views.SignupView.as_view(), name="signup"),
|
||||
path("accounts/", include("django.contrib.auth.urls")),
|
||||
path("accounts/login/", auth_views.LoginView.as_view(), name="login"),
|
||||
path("accounts/logout/", auth_views.LogoutView.as_view(), name="logout"),
|
||||
path(
|
||||
"accounts/password_change/",
|
||||
views.PasswordChangeView.as_view(),
|
||||
name="password_change",
|
||||
),
|
||||
path(
|
||||
"accounts/password_reset/",
|
||||
views.PasswordResetView.as_view(),
|
||||
name="password_reset",
|
||||
),
|
||||
path(
|
||||
"accounts/reset/<uidb64>/<token>/",
|
||||
views.PasswordResetConfirmView.as_view(),
|
||||
name="password_reset_confirm",
|
||||
),
|
||||
path("legal/", TemplateView.as_view(template_name="privacy.html"), name="legal"),
|
||||
]
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from django.contrib.auth import views as auth_views
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.messages.views import SuccessMessageMixin
|
||||
from django.shortcuts import redirect
|
||||
|
@ -22,3 +23,20 @@ class SignupView(SuccessMessageMixin, CreateView):
|
|||
form_class = forms.UserSignupForm
|
||||
success_url = reverse_lazy("login")
|
||||
success_message = "Le compte %(username)s a été créé avec succès."
|
||||
|
||||
|
||||
class PasswordChangeView(SuccessMessageMixin, auth_views.PasswordChangeView):
|
||||
success_message = "Le mot de passe a été changé avec succès."
|
||||
success_url = reverse_lazy("index")
|
||||
|
||||
|
||||
class PasswordResetView(SuccessMessageMixin, auth_views.PasswordResetView):
|
||||
success_message = "Un courriel a été envoyé avec les instructions pour réinitialiser votre mot de passe."
|
||||
success_url = reverse_lazy("login")
|
||||
|
||||
|
||||
class PasswordResetConfirmView(
|
||||
SuccessMessageMixin, auth_views.PasswordResetConfirmView
|
||||
):
|
||||
success_message = "Le mot de passe a été réinitialisé avec succès."
|
||||
success_url = reverse_lazy("login")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue