Fix password change URLs and add basic templates, to address #734

This commit is contained in:
Garret Wassermann 2019-03-09 18:38:24 -05:00
parent 59e58c6d0e
commit d42fc23e08
5 changed files with 76 additions and 1 deletions

View File

@ -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

View File

@ -72,7 +72,7 @@
</li>
<li><a href='{% url 'helpdesk:rss_index' %}'><i class="fa fa-rss-square fa-fw"></i> {% trans "RSS Feeds" %}</a></li>
{% if helpdesk_settings.HELPDESK_SHOW_CHANGE_PASSWORD and user.has_usable_password %}
<li><a href="{% url 'auth_password_change' %}"><i class="fa fa-user-secret fa-fw"></i> {% trans "Change password" %}</a></li>
<li><a href="{% url 'helpdesk:password_change' %}"><i class="fa fa-user-secret fa-fw"></i> {% trans "Change password" %}</a></li>
{% endif %}
<li class="divider"></li>
{% if user.is_superuser %}

View File

@ -0,0 +1,51 @@
{% extends "helpdesk/base.html" %}{% load i18n %}
{% block helpdesk_title %}{% trans "Change password" %}{% endblock %}
{% block helpdesk_body %}
<h3>{% trans "Change Password" %}</h3>
<form method="post">{% csrf_token %}
<div>
{% if form.errors %}
<p class="errornote">
{% if form.errors.items|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
</p>
{% endif %}
<p>{% 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." %}</p>
<fieldset class="module aligned wide">
<div class="form-row">
{{ form.old_password.errors }}
{{ form.old_password.label_tag }} {{ form.old_password }}
</div>
<div class="form-row">
{{ form.new_password1.errors }}
{{ form.new_password1.label_tag }} {{ form.new_password1 }}
{% if form.new_password1.help_text %}
<div class="help">{{ form.new_password1.help_text|safe }}</div>
{% endif %}
</div>
<div class="form-row">
{{ form.new_password2.errors }}
{{ form.new_password2.label_tag }} {{ form.new_password2 }}
{% if form.new_password2.help_text %}
<div class="help">{{ form.new_password2.help_text|safe }}</div>
{% endif %}
</div>
</fieldset>
<div class="submit-row">
<input type="submit" value="{% trans 'Change my password' %}" class="default">
</div>
</div>
</form>
{% endblock helpdesk_body %}

View File

@ -0,0 +1,10 @@
{% extends "helpdesk/base.html" %}{% load i18n %}
{% block helpdesk_title %}{% trans "Change password" %}{% endblock %}
{% block helpdesk_body %}
<h3>{% trans "Success!" %}</h3>
<p>{% trans 'Your password was changed.' %}</p>
{% endblock helpdesk_body %}

View File

@ -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: