From 849744e33775bd6b11c357c2129468f101a1795f Mon Sep 17 00:00:00 2001 From: Jannis Portmann Date: Sun, 16 Apr 2023 19:19:05 +0200 Subject: [PATCH] Password reset option --- .../registration/password_reset_complete.html | 5 +++++ .../registration/password_reset_confirm.html | 11 +++++++++++ .../templates/registration/verify_email.html | 11 +++++++++++ .../templates/registration/verify_email_done.html | 10 ++++++++++ pflaenzli/pflaenzli/templates/user/detail.html | 5 +++-- pflaenzli/pflaenzli/urls.py | 8 ++++++++ 6 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 pflaenzli/pflaenzli/templates/registration/password_reset_complete.html create mode 100644 pflaenzli/pflaenzli/templates/registration/password_reset_confirm.html create mode 100644 pflaenzli/pflaenzli/templates/registration/verify_email.html create mode 100644 pflaenzli/pflaenzli/templates/registration/verify_email_done.html diff --git a/pflaenzli/pflaenzli/templates/registration/password_reset_complete.html b/pflaenzli/pflaenzli/templates/registration/password_reset_complete.html new file mode 100644 index 0000000..62bcc1e --- /dev/null +++ b/pflaenzli/pflaenzli/templates/registration/password_reset_complete.html @@ -0,0 +1,5 @@ +{% extends 'base.html' %} +{% block content %} +

Reset password

+

New password was set successfully. Please login again.

+{% endblock %} diff --git a/pflaenzli/pflaenzli/templates/registration/password_reset_confirm.html b/pflaenzli/pflaenzli/templates/registration/password_reset_confirm.html new file mode 100644 index 0000000..935354f --- /dev/null +++ b/pflaenzli/pflaenzli/templates/registration/password_reset_confirm.html @@ -0,0 +1,11 @@ +{% extends 'base.html' %} +{% load crispy_forms_tags %} +{% block content %} +

Reset password

+

Choose a new password.

+
+ {% csrf_token %} + {{ form|crispy }} + +
+{% endblock %} diff --git a/pflaenzli/pflaenzli/templates/registration/verify_email.html b/pflaenzli/pflaenzli/templates/registration/verify_email.html new file mode 100644 index 0000000..19453d9 --- /dev/null +++ b/pflaenzli/pflaenzli/templates/registration/verify_email.html @@ -0,0 +1,11 @@ +{% extends 'base.html' %} +{% load crispy_forms_tags %} +{% block content %} +

Reset password

+

Enter the email of your account, you'll then recieve a reset link.

+
+ {% csrf_token %} + {{ form|crispy }} + +
+{% endblock %} diff --git a/pflaenzli/pflaenzli/templates/registration/verify_email_done.html b/pflaenzli/pflaenzli/templates/registration/verify_email_done.html new file mode 100644 index 0000000..4296909 --- /dev/null +++ b/pflaenzli/pflaenzli/templates/registration/verify_email_done.html @@ -0,0 +1,10 @@ +{% extends 'base.html' %} +{% block content %} +

Reset password

+

+ We've emailed you instructions for setting your password, if an account exists with the email you entered. You should receive them shortly. +

+

+ If you don't receive an email, please make sure you've entered the address you registered with, and check your spam folder. +

+{% endblock %} diff --git a/pflaenzli/pflaenzli/templates/user/detail.html b/pflaenzli/pflaenzli/templates/user/detail.html index 3deb4f9..319a222 100644 --- a/pflaenzli/pflaenzli/templates/user/detail.html +++ b/pflaenzli/pflaenzli/templates/user/detail.html @@ -4,14 +4,15 @@

User details {{ user.username }}

+
Some functions do not work yet!

Settings

- + Change Password

Delete Account

{% endblock %} diff --git a/pflaenzli/pflaenzli/urls.py b/pflaenzli/pflaenzli/urls.py index b156859..0b0d74d 100644 --- a/pflaenzli/pflaenzli/urls.py +++ b/pflaenzli/pflaenzli/urls.py @@ -19,6 +19,14 @@ urlpatterns = [ path('accounts/login/', auth_views.LoginView.as_view(template_name='registration/login.html')), path('accounts/profile/', auth_views.LoginView.as_view(template_name='user/detail.html'), name='user_profile'), path('accounts/register/', views.register_user, name='register_user'), + path('accounts/password_reset/', auth_views.PasswordResetView.as_view(template_name='registration/verify_email.html', + extra_context={'form_helper': settings.CRISPY_TEMPLATE_PACK}), name='password_reset'), + path('accounts/password_reset/done/', + auth_views.PasswordResetDoneView.as_view(template_name='registration/verify_email_done.html')), + path('accounts/reset///', + auth_views.PasswordResetConfirmView.as_view(template_name='registration/password_reset_confirm.html', extra_context={'form_helper': settings.CRISPY_TEMPLATE_PACK})), + path('accounts/reset///', + auth_views.PasswordResetCompleteView.as_view(template_name='registration/password_reset_complete.html')), path('accounts/', include('django.contrib.auth.urls')), path("faq/", TemplateView.as_view(template_name='app/faq.html'), name="faq"), path("imprint/", TemplateView.as_view(template_name='app/imprint.html'), name="imprint"),