Browse Source

First draft of user password reset form

Fabs 10 years ago
parent
commit
1be194f65b

+ 6 - 4
coin/members/templates/members/registration/password_change_done.html

@@ -4,8 +4,10 @@
 {% block title %}{% trans 'Password change successful' %}{% endblock %}
 
 {% block content %}
-
-    <h2>{% trans 'Password change successful' %}</h2>
-    <p>{% trans 'Your password was changed.' %}</p>
-
+<div class="row">
+    <div class="large-12 columns">
+        <h2>{% trans 'Password change successful' %}</h2>
+        <p>{% trans 'Your password was changed.' %}</p>
+    </div>
+</div>
 {% endblock %}

+ 21 - 0
coin/members/templates/members/registration/password_reset_complete.html

@@ -0,0 +1,21 @@
+{% extends "admin/base_site.html" %}
+{% load i18n %}
+
+{% block breadcrumbs %}
+<div class="breadcrumbs">
+<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
+&rsaquo; {% trans 'Password reset' %}
+</div>
+{% endblock %}
+
+{% block title %}{% trans 'Password reset complete' %}{% endblock %}
+
+{% block content %}
+
+<h1>{% trans 'Password reset complete' %}</h1>
+
+<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 %}

+ 37 - 0
coin/members/templates/members/registration/password_reset_confirm.html

@@ -0,0 +1,37 @@
+{% extends "admin/base_site.html" %}
+{% load i18n %}
+
+{% block breadcrumbs %}
+<div class="breadcrumbs">
+<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
+&rsaquo; {% trans 'Password reset confirmation' %}
+</div>
+{% endblock %}
+
+{% block title %}{% trans 'Password reset' %}{% endblock %}
+
+{% block content %}
+
+{% if validlink %}
+
+<h1>{% trans 'Enter new password' %}</h1>
+
+<p>{% trans "Please enter your new password twice so we can verify you typed it in correctly." %}</p>
+
+<form action="" method="post">{% csrf_token %}
+{{ form.new_password1.errors }}
+<p class="aligned wide"><label for="id_new_password1">{% trans 'New password:' %}</label>{{ form.new_password1 }}</p>
+{{ form.new_password2.errors }}
+<p class="aligned wide"><label for="id_new_password2">{% trans 'Confirm password:' %}</label>{{ form.new_password2 }}</p>
+<p><input type="submit" value="{% trans 'Change my password' %}" /></p>
+</form>
+
+{% else %}
+
+<h1>{% trans 'Password reset unsuccessful' %}</h1>
+
+<p>{% trans "The password reset link was invalid, possibly because it has already been used.  Please request a new password reset." %}</p>
+
+{% endif %}
+
+{% endblock %}

+ 21 - 0
coin/members/templates/members/registration/password_reset_done.html

@@ -0,0 +1,21 @@
+{% extends "admin/base_site.html" %}
+{% load i18n %}
+
+{% block breadcrumbs %}
+<div class="breadcrumbs">
+<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
+&rsaquo; {% trans 'Password reset' %}
+</div>
+{% endblock %}
+
+{% block title %}{% trans 'Password reset successful' %}{% endblock %}
+
+{% block content %}
+
+<h1>{% trans 'Password reset successful' %}</h1>
+
+<p>{% trans "We've emailed you instructions for setting your password. You should be receiving them shortly." %}</p>
+
+<p>{% trans "If you don't receive an email, please make sure you've entered the address you registered with, and check your spam folder." %}</p>
+
+{% endblock %}

+ 14 - 0
coin/members/templates/members/registration/password_reset_email.html

@@ -0,0 +1,14 @@
+{% load i18n %}{% autoescape off %}
+{% blocktrans %}You're receiving this email 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 'members:password_reset_confirm' uidb64=uid token=token %}
+{% endblock %}
+{% trans "Your username, in case you've forgotten:" %} {{ user.get_username }}
+
+{% trans "Thanks for using our site!" %}
+
+{% blocktrans %}The {{ site_name }} team{% endblocktrans %}
+
+{% endautoescape %}

+ 25 - 0
coin/members/templates/members/registration/password_reset_form.html

@@ -0,0 +1,25 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+
+<div class="row">
+    <div class="large-12 columns">
+        <h2>{% trans "Password reset" %}</h2>
+        <p>{% trans "Forgotten your password? Enter your email address below, and we'll email instructions for setting a new one." %}</p>
+    </div>
+</div>
+
+<div class="row">
+    <div class="large-12 columns">
+        <form action="" method="post">{% csrf_token %}
+            {{ form.email.errors }}
+            <label {% if form.id_email.errors %}class="error"{% endif %}>{% trans 'Email address' %}
+                {{ form.email }}
+            </label>
+
+            <input type="submit" value="{% trans 'Reset my password' %}" class="button radius" />
+        </form>
+    </div>
+</div>
+{% endblock %}

+ 14 - 0
coin/members/urls.py

@@ -12,6 +12,7 @@ urlpatterns = patterns(
         name = 'login'),
     url(r'^logout/$', 'django.contrib.auth.views.logout_then_login',
         name = 'logout'),
+    
     url(r'^password_change/$', 'django.contrib.auth.views.password_change', 
         {'post_change_redirect':'members:password_change_done',
         'template_name':'members/registration/password_change_form.html'},
@@ -19,6 +20,19 @@ urlpatterns = patterns(
     url(r'^password_change_done/$', 'django.contrib.auth.views.password_change_done',
         {'template_name':'members/registration/password_change_done.html'},
         name = 'password_change_done'),
+
+    url(r'^password_reset/$', 'django.contrib.auth.views.password_reset',
+        {'post_reset_redirect':'members:password_reset_done',
+        'template_name':'members/registration/password_reset_form.html',
+        'email_template_name':'members/registration/password_reset_email.html'},
+        name = 'password_reset'),
+    url(r'^password_reset_done/$', 'django.contrib.auth.views.password_reset_done',
+        {'template_name':'members/registration/password_reset_done.html',
+        'current_app':'members'},
+        name = 'password_reset_done'),
+    url(r'^password_reset_confirm/(?P<uidb64>.+)/(?P<token>.+)$', 'django.contrib.auth.views.password_reset_confirm',
+        {'template_name':'members/registration/password_reset_confirm.html'},
+        name = 'password_reset_confirm'),
         
 
     url(r'^detail/$',views.detail,