diff mbox

[1/5] login: add link to password reset

Message ID 1447188793-27228-2-git-send-email-rep.dot.nop@gmail.com
State Accepted
Headers show

Commit Message

Bernhard Reutner-Fischer Nov. 10, 2015, 8:53 p.m. UTC
Refurbished version from 2010

Doesn't mention the username in the mail but in the confirmation step.
Essentially the templates are all optional but they do look better (and
more integrated in patchwork) than the default django admin thing.

No testing beyond some bored clicking here and there.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
---
 patchwork/templates/patchwork/login.html           |  7 ++-
 patchwork/urls.py                                  |  9 ++++
 .../registration/password_reset_complete.html      |  9 ++++
 templates/registration/password_reset_confirm.html | 51 ++++++++++++++++++++++
 templates/registration/password_reset_done.html    | 13 ++++++
 templates/registration/password_reset_email.html   | 12 +++++
 templates/registration/password_reset_form.html    | 45 +++++++++++++++++++
 7 files changed, 145 insertions(+), 1 deletion(-)
 create mode 100644 templates/registration/password_reset_complete.html
 create mode 100644 templates/registration/password_reset_confirm.html
 create mode 100644 templates/registration/password_reset_done.html
 create mode 100644 templates/registration/password_reset_email.html
 create mode 100644 templates/registration/password_reset_form.html

Comments

Stephen Finucane Nov. 21, 2015, 6 p.m. UTC | #1
On 10 Nov 21:53, Bernhard Reutner-Fischer wrote:
> Refurbished version from 2010
> 
> Doesn't mention the username in the mail but in the confirmation step.
> Essentially the templates are all optional but they do look better (and
> more integrated in patchwork) than the default django admin thing.
> 
> No testing beyond some bored clicking here and there.
> 
> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>

I tested this and it all seems to work as expected. I removed the 'error'
class from the two "reset password" buttons as they "looked wrong".

Acked-by: Stephen Finucane <stephen.finucane@intel.com>

and merged.
diff mbox

Patch

diff --git a/patchwork/templates/patchwork/login.html b/patchwork/templates/patchwork/login.html
index 1f000e7..a28cd31 100644
--- a/patchwork/templates/patchwork/login.html
+++ b/patchwork/templates/patchwork/login.html
@@ -25,9 +25,14 @@ 
  {% endif %}
  {{ form }}
  <tr>
-  <td colspan="2" class="submitrow">
+  <td class="submitrow">
    <input type="submit" value="Login"/>
   </td>
+  <td class="submitrow">
+   <a href="{% url 'django.contrib.auth.views.password_reset' %}">
+     Forgot password?
+   </a>
+  </td>
  </tr>
 </table>
 </form>
diff --git a/patchwork/urls.py b/patchwork/urls.py
index b28eb90..d9da7db 100644
--- a/patchwork/urls.py
+++ b/patchwork/urls.py
@@ -52,6 +52,15 @@  urlpatterns = patterns('',
             name='password_change'),
     url(r'^user/password-change/done/$', auth_views.password_change_done,
             name='password_change_done'),
+    url(r'^user/password-reset/$', auth_views.password_reset,
+            name='password_reset'),
+    url(r'^user/password-reset/mail-sent/$', auth_views.password_reset_done,
+            name='password_reset_done'),
+    url(r'^user/password-reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
+            auth_views.password_reset_confirm,
+            name='password_reset_confirm'),
+    url(r'^user/password-reset/complete/$', auth_views.password_reset_complete,
+            name='password_reset_complete'),
 
     # login/logout
     url(r'^user/login/$', auth_views.login,
diff --git a/templates/registration/password_reset_complete.html b/templates/registration/password_reset_complete.html
new file mode 100644
index 0000000..1d88fdf
--- /dev/null
+++ b/templates/registration/password_reset_complete.html
@@ -0,0 +1,9 @@ 
+{% extends "base.html" %}
+
+{% block title %}Password reset completed{% endblock %}
+{% block heading %}Password reset completed{% endblock %}
+
+{% block body %}
+
+<p>Your password has been set.  You may go ahead and log in now.</p>
+{% endblock %}
diff --git a/templates/registration/password_reset_confirm.html b/templates/registration/password_reset_confirm.html
new file mode 100644
index 0000000..2ab1093
--- /dev/null
+++ b/templates/registration/password_reset_confirm.html
@@ -0,0 +1,51 @@ 
+{% extends "base.html" %}
+
+{% block title %}Password reset confirmation{% endblock %}
+{% block heading %}Password reset confirmation{% endblock %}
+
+{% block body %}
+
+{% if validlink %}
+<p>Your username, in case you've forgotten: {{ form.user.get_username }}</p>
+<p>Please enter your new password twice so we can verify you typed it in
+correctly</p>
+
+<form method="post">
+{% csrf_token %}
+
+<table class="form passwordform">
+
+{% if form.errors %}
+ <tr>
+  <td colspan="2" class="error">Please correct the errors below.</p>
+ </tr>
+{% endif %}
+
+
+{% for field in form %}
+  <tr>
+   <td>{{ field.label_tag }}</td>
+   <td>
+    {{ field.errors }}
+    {{ field }}
+{% if field.help_text %}
+    <div class="help_text"/>{{ field.help_text }}</div>
+{% endif %}
+   </td>
+  </tr>
+{% endfor %}
+
+ <tr>
+  <td colspan="2" class="error">
+   <input type="submit" value="Set my password" class="default" />
+  </td>
+ </tr>
+
+</table>
+
+</form>
+{% else %}
+<p>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/templates/registration/password_reset_done.html b/templates/registration/password_reset_done.html
new file mode 100644
index 0000000..fe9e551
--- /dev/null
+++ b/templates/registration/password_reset_done.html
@@ -0,0 +1,13 @@ 
+{% extends "base.html" %}
+
+{% block title %}Password reset{% endblock %}
+{% block heading %}Password reset{% endblock %}
+
+{% block body %}
+
+<p>We have emailed you instructions for setting your password.
+You should be receiving them shortly.</p>
+<p>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 %}
diff --git a/templates/registration/password_reset_email.html b/templates/registration/password_reset_email.html
new file mode 100644
index 0000000..fa399a4
--- /dev/null
+++ b/templates/registration/password_reset_email.html
@@ -0,0 +1,12 @@ 
+{% autoescape off %}Hi,
+
+You are receiving this email because you requested a password reset for
+your user account on the patchwork patch-tracking system.
+Please visit the following url and choose a new password:
+
+{% block reset_link %}
+{{ protocol }}://{{domain}}{% url 'password_reset_confirm' uidb64=uid token=token %}
+{% endblock %}
+
+Happy patchworking.
+{% endautoescape %}
diff --git a/templates/registration/password_reset_form.html b/templates/registration/password_reset_form.html
new file mode 100644
index 0000000..68e0ed1
--- /dev/null
+++ b/templates/registration/password_reset_form.html
@@ -0,0 +1,45 @@ 
+{% extends "base.html" %}
+
+{% block title %}Password reset{% endblock %}
+{% block heading %}Password reset{% endblock %}
+
+{% block body %}
+
+<p>Forgotten your password? Enter your email address below, and we will
+email instructions for setting a new one.</p>
+
+<form method="post">
+{% csrf_token %}
+
+<table class="form passwordform">
+
+{% if form.errors %}
+ <tr>
+  <td colspan="2" class="error">Please correct the errors below.</p>
+ </tr>
+{% endif %}
+
+
+{% for field in form %}
+  <tr>
+   <td>{{ field.label_tag }}</td>
+   <td>
+    {{ field.errors }}
+    {{ field }}
+{% if field.help_text %}
+    <div class="help_text"/>{{ field.help_text }}</div>
+{% endif %}
+   </td>
+  </tr>
+{% endfor %}
+
+ <tr>
+  <td colspan="2" class="error">
+   <input type="submit" value="Reset my password" class="default" />
+  </td>
+ </tr>
+
+</table>
+
+</form>
+{% endblock %}