diff --git a/wagtail/wagtailadmin/forms.py b/wagtail/wagtailadmin/forms.py index 9073e57c1e..1cb6a159f5 100644 --- a/wagtail/wagtailadmin/forms.py +++ b/wagtail/wagtailadmin/forms.py @@ -1,5 +1,6 @@ from django import forms -from django.contrib.auth.forms import AuthenticationForm +from django.contrib.auth import get_user_model +from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm class SearchForm(forms.Form): q = forms.CharField(label="Search term") @@ -28,3 +29,30 @@ class LoginForm(AuthenticationForm): password = forms.CharField( widget=forms.PasswordInput(attrs={'placeholder': "Enter password"}), ) + + +class PasswordResetForm(PasswordResetForm): + def clean(self): + cleaned_data = super(PasswordResetForm, self).clean() + + # Find users of this email address + UserModel = get_user_model() + email = cleaned_data['email'] + active_users = UserModel._default_manager.filter(email__iexact=email, is_active=True) + + if active_users.exists(): + # Check if all users of the email address are LDAP users (and give an error if they are) + found_non_ldap_user = False + for user in active_users: + if user.has_usable_password(): + found_non_ldap_user = True + break + + if not found_non_ldap_user: + # All found users are LDAP users, give error message + raise forms.ValidationError("Sorry, you cannot reset your password here as your user account is managed by another server.") + else: + # No user accounts exist + raise forms.ValidationError("This email address is not recognised.") + + return cleaned_data \ No newline at end of file diff --git a/wagtail/wagtailadmin/static/wagtailadmin/css/layouts/login.less b/wagtail/wagtailadmin/static/wagtailadmin/css/layouts/login.less index aac755ee42..298664a0c5 100644 --- a/wagtail/wagtailadmin/static/wagtailadmin/css/layouts/login.less +++ b/wagtail/wagtailadmin/static/wagtailadmin/css/layouts/login.less @@ -7,11 +7,12 @@ html{ height:100%; } body{ - margin-left: 0px; + padding:0 5%; height:100%; + color:white; + margin:0; } h1{ - .nice-padding(); font-weight:300; font-size:2em; line-height:1em; @@ -30,24 +31,68 @@ h1{ vertical-align: -15%; } } -form{ +.content-wrapper{ width:100%; - ul{ - .unlist(); + float:none; + background:none; + border:0; +} +.fields{ + .unlist(); + + li.full{ + overflow:hidden; + position:relative; + padding:0; + margin-bottom:1px; + + label{ + display:none; + } + input{ + border:0; + } + + label{ + .border-radius(2px); + text-transform:uppercase; + padding:2px 5px; + position:absolute; + top:0; + left:0; + margin-top:-1px; + font-size:0.7em; + z-index:1; + margin:0.2em 0; + line-height:1.5em; + font-weight:normal; + } + input{ + .border-radius(0px); + font-weight:300; + border:0; + padding-top:1.5em; + padding-bottom:1.5em; + font-size:1.6em; + line-height:1.6em; + } } - .fields li{ - .nice-padding(); - padding-top:1em; - padding-bottom:1em; + li:first-child input{ + border-top:0; } - .fields .checkbox{ + .checkbox{ padding-top:2em; padding-bottom:2em; } + .field{ + padding:0; + } + + .field.icon:before{ + display:none; + } } -label{ - color:white; -} + input[type=submit]{ font-size:1.5em; padding:1.1em 2.4em; @@ -57,55 +102,7 @@ input[type=checkbox]:before{ color:#555; border:1px solid #555; } -.fields li.full{ - position:relative; - padding:0; - - label{ - display:none; - } - input{ - border-top: 1px dashed @color-input-border; - } -} -.fields li:first-child input{ - border-top:0; -} -.field{ - padding:0; -} -.field.icon:before{ - display:none; -} - - -.full label{ - .border-radius(2px); - text-transform:uppercase; - padding:2px 5px; - position:absolute; - top:0; - left:0; - margin-top:-1px; - font-size:0.7em; - z-index:1; - margin:0.2em 0; - line-height:1.5em; - font-weight:normal; -} - -/* Special full-width, one-off fields i.e a single text or textarea input */ -.full input{ - .nice-padding; - .border-radius(0px); - font-weight:300; - border:0; - padding-top:1.5em; - padding-bottom:1.5em; - font-size:1.6em; - line-height:1.6em; -} .help{ opacity:1; position:absolute; @@ -118,6 +115,7 @@ input[type=checkbox]:before{ @media screen and (min-width: @breakpoint-mobile){ body{ font-size:85%; + padding:0 10%; } /* centres login form vertically */ @@ -132,44 +130,43 @@ input[type=checkbox]:before{ margin-left:-4px; } } - form{ + .content-wrapper{ width:100%; display:inline-block; vertical-align: middle; - - .fields li{ - padding-left:10%; - } } h1{ - padding-left:10%; font-weight:300; font-size:4em; line-height:1em; } - .full input{ - padding-left:10%; - } - .field.icon:before{ - display:inline-block; - position: absolute; - color:@color-grey-4; - border: 2px solid @color-grey-4; - border-radius: 100%; - width: 1em; - padding: 0.3em; - left: 12%; - margin-left: 80px; - margin-left: -25px; - top: 50%; - margin-top: -25px; - } - .full input{ - padding-left:15%; + .fields{ + .field.icon:before{ + display:inline-block; + position: absolute; + color:@color-grey-4; + border: 2px solid @color-grey-4; + border-radius: 100%; + width: 1em; + padding: 0.3em; + left: 12%; + margin-left: -25px; + margin-top: -25px; + top: 50%; + } + .full{ + margin:0 -13%; + } + .full input{ + padding-left:15%; + } + .submit{ + margin-top:2em; + } } - .messages li{ - padding-left:11%; + .messages{ + margin:0 -13% } } \ No newline at end of file diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/account/account.html b/wagtail/wagtailadmin/templates/wagtailadmin/account/account.html new file mode 100644 index 0000000000..92fb8f585e --- /dev/null +++ b/wagtail/wagtailadmin/templates/wagtailadmin/account/account.html @@ -0,0 +1,31 @@ +{% extends "wagtailadmin/base.html" %} + +{% block content %} +
+

Account

+
+ +
+ +
+{% endblock %} \ No newline at end of file diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/account/change_password.html b/wagtail/wagtailadmin/templates/wagtailadmin/account/change_password.html new file mode 100644 index 0000000000..f3ae9b5103 --- /dev/null +++ b/wagtail/wagtailadmin/templates/wagtailadmin/account/change_password.html @@ -0,0 +1,23 @@ +{% extends "wagtailadmin/base.html" %} + +{% block content %} +
+

Change password

+
+ +
+ {% if can_change_password %} +
+ {% csrf_token %} + + +
+ {% else %} +

Your password can't be changed here. Please contact a site administrator.

+ {% endif %} +
+{% endblock %} \ No newline at end of file diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/complete.html b/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/complete.html new file mode 100644 index 0000000000..68537aba4f --- /dev/null +++ b/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/complete.html @@ -0,0 +1,17 @@ +{% extends "wagtailadmin/skeleton.html" %} +{% load compress %} +{% block titletag %}Reset password{% endblock %} +{% block bodyclass %}login{% endblock %} + +{% block extra_css %} + {% compress css %} + + {% endcompress %} +{% endblock %} + +{% block furniture %} +
+

Password change successful

+

Login

+
+{% endblock %} \ No newline at end of file diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/confirm.html b/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/confirm.html new file mode 100644 index 0000000000..c3c9a1a3af --- /dev/null +++ b/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/confirm.html @@ -0,0 +1,45 @@ +{% extends "wagtailadmin/skeleton.html" %} +{% load compress %} +{% block titletag %}Set your new password{% endblock %} +{% block bodyclass %}login{% endblock %} + +{% block extra_css %} + {% compress css %} + + {% endcompress %} +{% endblock %} + +{% block furniture %} +
+
+ {% csrf_token %} +

Set your new password

+ + {% if form.errors %} +
+
    +
  • The passwords do not match. Please try again.
  • +
+
+ {% endif %} + + +
+
+{% endblock %} \ No newline at end of file diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/done.html b/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/done.html new file mode 100644 index 0000000000..d9df715b14 --- /dev/null +++ b/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/done.html @@ -0,0 +1,17 @@ +{% extends "wagtailadmin/skeleton.html" %} +{% load compress %} +{% block titletag %}Reset password{% endblock %} +{% block bodyclass %}login{% endblock %} + +{% block extra_css %} + {% compress css %} + + {% endcompress %} +{% endblock %} + +{% block furniture %} +
+

Check your email

+

A link to reset your password has been emailed to you.

+
+{% endblock %} \ No newline at end of file diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/email.txt b/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/email.txt new file mode 100644 index 0000000000..2fbc72097e --- /dev/null +++ b/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/email.txt @@ -0,0 +1,2 @@ +Please follow the link below to reset your password +{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %} \ No newline at end of file diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/email_subject.txt b/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/email_subject.txt new file mode 100644 index 0000000000..bca0a5e0b3 --- /dev/null +++ b/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/email_subject.txt @@ -0,0 +1 @@ +Password reset \ No newline at end of file diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/form.html b/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/form.html new file mode 100644 index 0000000000..d36f1b1561 --- /dev/null +++ b/wagtail/wagtailadmin/templates/wagtailadmin/account/password_reset/form.html @@ -0,0 +1,43 @@ +{% extends "wagtailadmin/skeleton.html" %} +{% load compress %} +{% block titletag %}Reset password{% endblock %} +{% block bodyclass %}login{% endblock %} + +{% block extra_css %} + {% compress css %} + + {% endcompress %} +{% endblock %} + +{% block furniture %} +
+
+ {% csrf_token %} +

Reset your password

+ +

Enter your email address in the box below

+ + {% if form.non_field_errors %} +
+
    + {% for error in form.non_field_errors %} +
  • {{ error }}
  • + {% endfor %} +
+
+ {% endif %} + + +
+
+{% endblock %} \ No newline at end of file diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/login.html b/wagtail/wagtailadmin/templates/wagtailadmin/login.html index a1a1b1066e..d902dd586e 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/login.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/login.html @@ -10,47 +10,46 @@ {% endblock %} {% block furniture %} -
- {% csrf_token %} - -

Sign in to Verdant

+
+ + {% csrf_token %} + +

Sign in to Verdant

- {% if form.errors %} -
-
    -
  • Your username and password didn't match. Please try again.
  • -
-
- {% endif %} - - - + {% endif %} + + + +
{% endblock %} \ No newline at end of file diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/shared/field_as_li.html b/wagtail/wagtailadmin/templates/wagtailadmin/shared/field_as_li.html index ecfc3f2e23..10000bb981 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/shared/field_as_li.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/shared/field_as_li.html @@ -1,5 +1,5 @@ {% load fieldtype %} -
  • +
  • {% if field|fieldtype != "boolean_field" %}{{ field.label_tag }}{% endif %} {% block form_field %} diff --git a/wagtail/wagtailadmin/templates/wagtailadmin/shared/main_nav.html b/wagtail/wagtailadmin/templates/wagtailadmin/shared/main_nav.html index 4e4553ba0e..ee2c2441b2 100644 --- a/wagtail/wagtailadmin/templates/wagtailadmin/shared/main_nav.html +++ b/wagtail/wagtailadmin/templates/wagtailadmin/shared/main_nav.html @@ -1,4 +1,5 @@ {% load gravatar wagtailadmin_nav %} +