changeset 78:4edfea7f8620

#29 - Implementing the forgotten password reset process.
author Brian Neal <bgneal@gmail.com>
date Sun, 12 Jul 2009 18:02:44 +0000
parents d5eed0a91a05
children 4b90d00cc4eb
files gpp/accounts/urls.py gpp/templates/accounts/login.html gpp/templates/accounts/password_reset.html gpp/templates/accounts/password_reset_complete.html gpp/templates/accounts/password_reset_email.txt gpp/templates/accounts/password_reset_sent.html
diffstat 6 files changed, 70 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/gpp/accounts/urls.py	Fri Jul 10 23:56:02 2009 +0000
+++ b/gpp/accounts/urls.py	Sun Jul 12 18:02:44 2009 +0000
@@ -9,17 +9,38 @@
 )
 
 urlpatterns += patterns('',
-    url(r'^login/',
+    url(r'^login/$',
         'django.contrib.auth.views.login',
         kwargs={'template_name': 'accounts/login.html'},
         name='accounts-login'),
-    url(r'^logout/',
+    url(r'^logout/$',
         'django.contrib.auth.views.logout',
         kwargs={'template_name': 'accounts/logout.html'},
         name='accounts-logout'), 
-    (r'^password/', 
+    (r'^password/$', 
         'django.contrib.auth.views.password_change', 
         {'template_name': 'accounts/password_change.html',
          'post_change_redirect': settings.LOGIN_REDIRECT_URL}),
+    url(r'^password/reset/$', 
+        'django.contrib.auth.views.password_reset', 
+        kwargs={'template_name': 'accounts/password_reset.html',
+         'email_template_name': 'accounts/password_reset_email.txt',
+         'post_reset_redirect': '/accounts/password/reset/sent/'},
+        name='accounts-password_reset'),
+    url(r'^password/reset/sent/$',
+        'django.contrib.auth.views.password_reset_done',
+        kwargs={'template_name': 'accounts/password_reset_sent.html'},
+        name='accounts-password_reset_sent'),
+    url(r'^password/reset/confirm/(?P<uidb36>[0-9a-z]+)/(?P<token>[0-9a-z]+-\w+)/$',
+        'django.contrib.auth.views.password_reset_confirm',
+        kwargs={
+            'template_name': 'accounts/password_reset_confirm.html',
+            'post_reset_redirect': '/accounts/password/reset/success/',
+            },
+        name='accounts-password_reset_confirm'),
+    url(r'^password/reset/success/$',
+        'django.contrib.auth.views.password_reset_complete',
+        kwargs={'template_name': 'accounts/password_reset_complete.html'},
+        name='accounts-password_reset_success'),
 )
 
--- a/gpp/templates/accounts/login.html	Fri Jul 10 23:56:02 2009 +0000
+++ b/gpp/templates/accounts/login.html	Sun Jul 12 18:02:44 2009 +0000
@@ -14,7 +14,7 @@
       <input type="hidden" name="next" value="{{ next }}" /></td></tr>
 </table>
 </form>
-<p>Forgot your password? You can reset it <a href="{% url accounts.views.register %}">here</a>.</p>
-<p>Don't have an account? Why don't you <a href="{% url accounts.views.register %}">register</a>?</p>
+<p>Forgot your password? You can reset it <a href="{% url accounts-password_reset %}">here</a>.</p>
+<p>Don't have an account? Why don't you <a href="{% url accounts-register %}">register</a>?</p>
 
 {% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gpp/templates/accounts/password_reset.html	Sun Jul 12 18:02:44 2009 +0000
@@ -0,0 +1,15 @@
+{% extends 'base.html' %}
+{% block title %}Reset Password{% endblock %}
+{% block content %}
+<h2>Reset Password</h2>
+<p>Forgot your password? No problem. Just enter your email address and we will
+email you instructions on how to reset it. 
+</p>
+<form method="post" action=".">
+<table>
+{{ form.as_table }}
+<tr><td>&nbsp;</td><td><input type="submit" value="Reset Password" />
+      </td></tr>
+</table>
+</form>
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gpp/templates/accounts/password_reset_complete.html	Sun Jul 12 18:02:44 2009 +0000
@@ -0,0 +1,8 @@
+{% extends 'base.html' %}
+{% block title %}Password Reset Complete{% endblock %}
+{% block content %}
+<h2>Password Reset Complete</h2>
+<p>
+Your password has been successfully changed. You may now <a href="{% url accounts-login %}">login</a>.
+</p>
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gpp/templates/accounts/password_reset_email.txt	Sun Jul 12 18:02:44 2009 +0000
@@ -0,0 +1,11 @@
+Hello,
+
+{{ site_name }} has received a request to reset the password for the user '{{ user }}'. If you didn't request this change, you can safely ignore this email.
+
+If you did request a password reset, please visit the following link, where you will be able to enter your new password:
+
+{{ protocol }}://{{ domain }}/accounts/password/reset/confirm/{{ uid }}/{{ token }}/
+
+Regards,
+
+The staff at {{ site_name }}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gpp/templates/accounts/password_reset_sent.html	Sun Jul 12 18:02:44 2009 +0000
@@ -0,0 +1,10 @@
+{% extends 'base.html' %}
+{% block title %}Password Reset Instructions Sent{% endblock %}
+{% block content %}
+<h2>Password Reset Instructions Sent</h2>
+<p>
+Instructions on how to reset your password have been sent to your email address. Please visit the
+link provided in the email to reset your password.
+</p>
+<p>If you do not receive the email within a few minutes, please check any spam folders.</p>
+{% endblock %}