From 504773e01ec048e97d84ceb4c46cec7609ebf498 Mon Sep 17 00:00:00 2001 From: sebastian Date: Sat, 9 Nov 2013 20:21:07 +0100 Subject: [PATCH] Added password reset --- static_common/css/layout.css | 7 +++- static_common/css/layout.scss | 9 +++++ users/templates/users/login.html | 7 ++-- users/templates/users/password_reset.html | 39 +++++++++++++++++++ .../users/password_reset_confirm.html | 39 +++++++++++++++++++ .../templates/users/password_reset_sent.html | 34 ++++++++++++++++ users/urls.py | 20 ++++++++-- users/views.py | 2 +- 8 files changed, 149 insertions(+), 8 deletions(-) create mode 100644 users/templates/users/password_reset.html create mode 100644 users/templates/users/password_reset_confirm.html create mode 100644 users/templates/users/password_reset_sent.html diff --git a/static_common/css/layout.css b/static_common/css/layout.css index 5d60e57..fcdb41a 100644 --- a/static_common/css/layout.css +++ b/static_common/css/layout.css @@ -40,7 +40,9 @@ border-style: solid; border-color: #eeeeee; border-radius: 3px; - background-color: #eee; } + background-color: #eee; + padding-top: 4px; + padding-left: 4px; } .textcontainer .uploads-list { list-style: none; } .textcontainer .uploads-list a { @@ -53,6 +55,9 @@ color: #e9322d; } .textcontainer .pure-form .browsebutton { font-size: 85%; } + .textcontainer .resetlink { + font-size: 75%; + text-decoration: none; } .button-green { background-color: #1CB841; diff --git a/static_common/css/layout.scss b/static_common/css/layout.scss index b2d2802..3193eee 100644 --- a/static_common/css/layout.scss +++ b/static_common/css/layout.scss @@ -53,6 +53,10 @@ @include gridcontainer; @include roundconers(#eee,6px); background-color: #eee; + padding:{ + top: 4px; + left: 4px; + } .uploads-list { list-style: none; @@ -77,6 +81,11 @@ font-size: 85%; } } + + .resetlink { + font-size: 75%; + text-decoration: none; + } } diff --git a/users/templates/users/login.html b/users/templates/users/login.html index 965e703..c080ad5 100644 --- a/users/templates/users/login.html +++ b/users/templates/users/login.html @@ -21,10 +21,11 @@
{% if user.is_authenticated %} - You are already logged in !
- Did you mean: logout ? + You are already logged in !
+ Did you mean: logout ? {% else %} - {% include 'form.html' with button_text='Login' %} + {% include 'form.html' with button_text='Login' %}
+ Oh well, I fogot my password ... {% endif %}
diff --git a/users/templates/users/password_reset.html b/users/templates/users/password_reset.html new file mode 100644 index 0000000..2188a67 --- /dev/null +++ b/users/templates/users/password_reset.html @@ -0,0 +1,39 @@ +{% extends "base.html" %} + + +{% block title %} Reset password {% endblock %} + + +{% block headeraddons %} + + +{% endblock %} + + +{% block content %} +
+
+ +
+ +

Reset password

+
+
+
+ {% if user.is_authenticated %} + You are already logged in !
+ Why would you want to reset your password if you still can log in ?
+ Please log out first.
+ {% else %} + Please provide email address you signed up with.
+
+ {% include 'form.html' with button_text='Reset' %} + {% endif %} +
+
+
+ {% include 'pastebin/latest_geometries.html' %} +
+
+
+{% endblock %} \ No newline at end of file diff --git a/users/templates/users/password_reset_confirm.html b/users/templates/users/password_reset_confirm.html new file mode 100644 index 0000000..17096f3 --- /dev/null +++ b/users/templates/users/password_reset_confirm.html @@ -0,0 +1,39 @@ +{% extends "base.html" %} + + +{% block title %} Login {% endblock %} + + +{% block headeraddons %} + + +{% endblock %} + + +{% block content %} +
+
+ +
+ +

Reset password

+
+
+
+ {% if user.is_authenticated %} + You are already logged in !
+ Why would you want to reset your password if you still can log in ?
+ Please log out first.
+ {% else %} + Please set a new password.
+
+ {% include 'form.html' with button_text='Reset' %} + {% endif %} +
+
+
+ {% include 'pastebin/latest_geometries.html' %} +
+
+
+{% endblock %} \ No newline at end of file diff --git a/users/templates/users/password_reset_sent.html b/users/templates/users/password_reset_sent.html new file mode 100644 index 0000000..f5d293e --- /dev/null +++ b/users/templates/users/password_reset_sent.html @@ -0,0 +1,34 @@ +{% extends "base.html" %} + + +{% block title %} Password reset email sent {% endblock %} + + +{% block headeraddons %} + + +{% endblock %} + + +{% block content %} +
+
+ +
+ +

Reset email sent

+
+
+
+ You should have received an email containg password reset link. +
+
+ Okay +
+
+
+ {% include 'pastebin/latest_geometries.html' %} +
+
+
+{% endblock %} \ No newline at end of file diff --git a/users/urls.py b/users/urls.py index e425493..ebc39a3 100644 --- a/users/urls.py +++ b/users/urls.py @@ -3,7 +3,7 @@ from django.core.urlresolvers import reverse_lazy from pastebin.models import Geometry -from views import UserCreateView, UserUpdateView, SendConfirmationView, CheckConfirmationView +from views import * urlpatterns = patterns('', url(r'^signup/$', UserCreateView.as_view(), name='signup'), @@ -12,12 +12,26 @@ urlpatterns = patterns('', url(r'^update/(?P\d+)/$', UserUpdateView.as_view(), name='user_update'), + url(r'^password/reset/$', 'django.contrib.auth.views.password_reset', {'extra_context' : {'latest_geometries' : Geometry.get_latest()}, + 'template_name' : 'users/password_reset.html', + 'post_reset_redirect' : reverse_lazy('password_reset_sent')}, + name='password_reset'), + + url(r'^password/reset/(?P[0-9A-Za-z]+)/(?P.+)/$', 'django.contrib.auth.views.password_reset_confirm', {'extra_context' : {'latest_geometries' : Geometry.get_latest()}, + 'template_name' : 'users/password_reset_confirm.html', + 'post_reset_redirect' : reverse_lazy('login')}, + name='password_reset_confirm'), + + url(r'^password/reset/sent/$', 'django.contrib.auth.views.password_reset_done', {'extra_context' : {'latest_geometries' : Geometry.get_latest()}, + 'template_name' : 'users/password_reset_sent.html',}, + name='password_reset_sent'), + + url(r'^login/$', 'django.contrib.auth.views.login', {'extra_context' : {'latest_geometries' : Geometry.get_latest()}, 'template_name' : 'users/login.html'}, name='login'), + url(r'^logout/$', 'django.contrib.auth.views.logout',{'extra_context' : {'latest_geometries' : Geometry.get_latest()}, 'next_page' : reverse_lazy('login')}, name='logout'), - - ) \ No newline at end of file diff --git a/users/views.py b/users/views.py index 07dea10..43da46b 100644 --- a/users/views.py +++ b/users/views.py @@ -101,4 +101,4 @@ class CheckConfirmationView(TemplateView, LastesGeometriesMixin): print "Acitvating %s" % user.username - return super(CheckConfirmationView,self).get(self, request, *args, **kwargs) \ No newline at end of file + return super(CheckConfirmationView,self).get(self, request, *args, **kwargs)