Self hosted FLOSS fitness/workout, nutrition and weight tracker
Add password reset functionality
Roland Geider2e3d9237a1c1
diff --git a/manager/templates/user/login.html b/manager/templates/user/login.htmlindex 292734489..42f5bd8af 100644--- a/manager/templates/user/login.html+++ b/manager/templates/user/login.html@@ -21,7 +21,7 @@{% include "form_snippet.html" with field=form.password %}<tr><td colspan="2">- <input type="submit" value="{% trans 'Save' %}" id="form-save">+ <input type="submit" value="{% trans 'Login' %}" id="form-save"></td></tr></table>@@ -34,4 +34,10 @@{% block sidebar %}<h3>{% trans "No account?" %}</h3><p><a href="{% url manager.views.registration %}">{% trans "Register" %}</a></p>++<h3>{% trans "Forgot password?" %}</h3>+<p><a href="{% url django.contrib.auth.views.password_reset %}">{% trans "Reset password" %}</a></p>+++{% endblock %}diff --git a/manager/templates/user/password_reset_complete.html b/manager/templates/user/password_reset_complete.htmlnew file mode 100644index 000000000..eabd31490--- /dev/null+++ b/manager/templates/user/password_reset_complete.html@@ -0,0 +1,15 @@+{% extends "base.html" %}+{% load i18n %}++{% block title %}{% trans "Password reset complete" %}{% endblock %}+++{% block content %}++<h2>{% trans 'Password reset complete' %}</h2>++<p>{% trans "Your password has been set. You may go ahead and log in now." %}</p>++<p><a href="{{ login_url }}">{% trans 'Log in' %}</a></p>++{% endblock %}diff --git a/manager/templates/user/password_reset_confirm.html b/manager/templates/user/password_reset_confirm.htmlnew file mode 100644index 000000000..a47c41f3f--- /dev/null+++ b/manager/templates/user/password_reset_confirm.html@@ -0,0 +1,35 @@+{% extends "base.html" %}+{% load i18n %}++{% block title %}{% trans "Password reset confirmation" %}{% endblock %}+++{% block content %}++{% if validlink %}+<h2>{% trans 'Enter new password' %}</h2>+<p>{% trans "Please enter your new password twice so we can verify you typed it in correctly." %}</p>++<form action=""+ method="post"+ class="ym-form">+ {% csrf_token %}++ <table>+{% include "form_snippet.html" with field=form.new_password1 %}+{% include "form_snippet.html" with field=form.new_password2 %}+ <tr>+ <td colspan="2">+ <input type="submit" value="{% trans 'Change my password' %}" id="form-save">+ </td>+ </tr>+ </table>+</form>++{% else %}++<h2>{% trans 'Password reset unsuccessful' %}</h2>+<p>{% trans "The password reset link was invalid, possibly because it has already been used. Please request a new password reset." %}</p>+{% endif %}++{% endblock %}diff --git a/manager/templates/user/password_reset_done.html b/manager/templates/user/password_reset_done.htmlnew file mode 100644index 000000000..adf2a48fb--- /dev/null+++ b/manager/templates/user/password_reset_done.html@@ -0,0 +1,13 @@+{% extends "base.html" %}+{% load i18n %}++{% block title %}{% trans "Password reset successful" %}{% endblock %}+++{% block content %}++<h2>{% trans 'Password reset successful' %}</h2>++<p>{% trans "We've e-mailed you instructions for setting your password to the e-mail address you submitted. You should be receiving it shortly." %}</p>++{% endblock %}\ No newline at end of filediff --git a/manager/templates/user/password_reset_email.html b/manager/templates/user/password_reset_email.htmlnew file mode 100644index 000000000..de9dc79c5--- /dev/null+++ b/manager/templates/user/password_reset_email.html@@ -0,0 +1,14 @@+{% load i18n %}{% load url from future %}{% autoescape off %}+{% blocktrans %}You're receiving this e-mail because you requested a password reset for your user account at {{ site_name }}.{% endblocktrans %}++{% trans "Please go to the following page and choose a new password:" %}+{% block reset_link %}+{{ protocol }}://{{ domain }}{% url 'django.contrib.auth.views.password_reset_confirm' uidb36=uid token=token %}+{% endblock %}+{% trans "Your username, in case you've forgotten:" %} {{ user.username }}++{% trans "Thanks for using our site!" %}++{% blocktrans %}The {{ site_name }} team{% endblocktrans %}++{% endautoescape %}diff --git a/manager/templates/user/password_reset_form.html b/manager/templates/user/password_reset_form.htmlnew file mode 100644index 000000000..f5712a0f6--- /dev/null+++ b/manager/templates/user/password_reset_form.html@@ -0,0 +1,24 @@+{% extends "base.html" %}+{% load i18n %}++{% block title %}{% trans "Password reset" %}{% endblock %}+++{% block content %}+<h2>{% trans "Password reset" %}</h2>++<form action=""+ method="post"+ class="ym-form">+ {% csrf_token %}+ {{ form.non_field_errors }}+<table>+{% include "form_snippet.html" with field=form.email %}+ <tr>+ <td colspan="2">+ <input type="submit" value="{% trans 'Send' %}" id="form-save">+ </td>+ </tr>+</table>+</form>+{% endblock %}\ No newline at end of filediff --git a/manager/urls.py b/manager/urls.pyindex d81d08962..535323cdd 100644--- a/manager/urls.py+++ b/manager/urls.py@@ -14,11 +14,12 @@ urlpatterns = patterns('manager.views',url(r'^$', 'index'),# User- url(r'^login$', 'login'),- url(r'^logout$', 'logout'),+ url(r'^login$', 'login', name='login'),+ url(r'^logout$', 'logout', name='logout'),url(r'^user/registration$', 'registration'),url(r'^user/preferences$', 'preferences'),url(r'^user/password/change$', 'change_password'),+# Workouturl(r'^workout/overview$', 'overview'),@@ -60,3 +61,24 @@ urlpatterns = patterns('manager.views',# PDF stuff is in a different fileurlpatterns = urlpatterns + patterns('manager.pdf',url(r'^workout/(?P<id>\d+)/pdf/$', 'workout_log'))++# Password reset is implemented by Django, no need to cook our own soup here+# (besides the templates)+urlpatterns = urlpatterns + patterns('',+ url(r'^user/password/reset/$',+ 'django.contrib.auth.views.password_reset',+ {'template_name': 'user/password_reset_form.html'},+ name='password_reset'),+ url(r'^user/password/reset/done/$',+ 'django.contrib.auth.views.password_reset_done',+ {'template_name': 'user/password_reset_done.html'},+ name='password_reset_done'),+ url(r'^user/password/reset/check/(?P<uidb36>[0-9A-Za-z]{1,13})-(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',+ 'django.contrib.auth.views.password_reset_confirm',+ {'template_name': 'user/password_reset_confirm.html'},+ name='password_reset_confirm'),+ url(r'^user/password/reset/complete/$',+ 'django.contrib.auth.views.password_reset_complete',+ {'template_name': 'user/password_reset_complete.html'},+ name='password_reset_complete'),+ )\ No newline at end of file