From d42fc23e08bd49094d35aac71b77bf264cf17ffa Mon Sep 17 00:00:00 2001 From: Garret Wassermann Date: Sat, 9 Mar 2019 18:38:24 -0500 Subject: [PATCH] Fix password change URLs and add basic templates, to address #734 --- demo/demodesk/config/settings.py | 3 ++ helpdesk/templates/helpdesk/navigation.html | 2 +- .../registration/change_password.html | 51 +++++++++++++++++++ .../registration/change_password_done.html | 10 ++++ helpdesk/urls.py | 11 ++++ 5 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 helpdesk/templates/helpdesk/registration/change_password.html create mode 100644 helpdesk/templates/helpdesk/registration/change_password_done.html diff --git a/demo/demodesk/config/settings.py b/demo/demodesk/config/settings.py index 256f1f15..2fb335c8 100644 --- a/demo/demodesk/config/settings.py +++ b/demo/demodesk/config/settings.py @@ -98,6 +98,9 @@ HELPDESK_SUBMIT_A_TICKET_PUBLIC = True # Should the Knowledgebase be enabled? HELPDESK_KB_ENABLED = True +# Allow users to change their passwords +HELPDESK_SHOW_CHANGE_PASSWORD = True + # Instead of showing the public web portal first, # we can instead redirect users straight to the login page. HELPDESK_REDIRECT_TO_LOGIN_BY_DEFAULT = False diff --git a/helpdesk/templates/helpdesk/navigation.html b/helpdesk/templates/helpdesk/navigation.html index 0121c4fb..f4311844 100644 --- a/helpdesk/templates/helpdesk/navigation.html +++ b/helpdesk/templates/helpdesk/navigation.html @@ -72,7 +72,7 @@
  • {% trans "RSS Feeds" %}
  • {% if helpdesk_settings.HELPDESK_SHOW_CHANGE_PASSWORD and user.has_usable_password %} -
  • {% trans "Change password" %}
  • +
  • {% trans "Change password" %}
  • {% endif %}
  • {% if user.is_superuser %} diff --git a/helpdesk/templates/helpdesk/registration/change_password.html b/helpdesk/templates/helpdesk/registration/change_password.html new file mode 100644 index 00000000..6867df0c --- /dev/null +++ b/helpdesk/templates/helpdesk/registration/change_password.html @@ -0,0 +1,51 @@ +{% extends "helpdesk/base.html" %}{% load i18n %} +{% block helpdesk_title %}{% trans "Change password" %}{% endblock %} + +{% block helpdesk_body %} + +

    {% trans "Change Password" %}

    + +
    {% csrf_token %} +
    +{% if form.errors %} +

    + {% if form.errors.items|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %} +

    +{% endif %} + + +

    {% trans "Please enter your old password, for security's sake, and then enter your new password twice so we can verify you typed it in correctly." %}

    + +
    + +
    + {{ form.old_password.errors }} + {{ form.old_password.label_tag }} {{ form.old_password }} +
    + +
    + {{ form.new_password1.errors }} + {{ form.new_password1.label_tag }} {{ form.new_password1 }} + {% if form.new_password1.help_text %} +
    {{ form.new_password1.help_text|safe }}
    + {% endif %} +
    + +
    +{{ form.new_password2.errors }} + {{ form.new_password2.label_tag }} {{ form.new_password2 }} + {% if form.new_password2.help_text %} +
    {{ form.new_password2.help_text|safe }}
    + {% endif %} +
    + +
    + +
    + +
    + +
    +
    + +{% endblock helpdesk_body %} diff --git a/helpdesk/templates/helpdesk/registration/change_password_done.html b/helpdesk/templates/helpdesk/registration/change_password_done.html new file mode 100644 index 00000000..e5e1db8b --- /dev/null +++ b/helpdesk/templates/helpdesk/registration/change_password_done.html @@ -0,0 +1,10 @@ +{% extends "helpdesk/base.html" %}{% load i18n %} +{% block helpdesk_title %}{% trans "Change password" %}{% endblock %} + +{% block helpdesk_body %} + +

    {% trans "Success!" %}

    + +

    {% trans 'Your password was changed.' %}

    + +{% endblock helpdesk_body %} diff --git a/helpdesk/urls.py b/helpdesk/urls.py index c6c7379f..0dae640a 100644 --- a/helpdesk/urls.py +++ b/helpdesk/urls.py @@ -194,6 +194,17 @@ urlpatterns += [ template_name='helpdesk/registration/login.html', next_page='../'), name='logout'), + + url(r'^password_change/$', + auth_views.PasswordChangeView.as_view( + template_name='helpdesk/registration/change_password.html', + success_url='./done'), + name='password_change'), + + url(r'^password_change/done$', + auth_views.PasswordChangeDoneView.as_view( + template_name='helpdesk/registration/change_password_done.html',), + name='password_change_done'), ] if helpdesk_settings.HELPDESK_KB_ENABLED: