diff --git a/demo/demo/settings.py b/demo/demo/settings.py index 403947cf..71240912 100644 --- a/demo/demo/settings.py +++ b/demo/demo/settings.py @@ -68,6 +68,19 @@ # Make this unique, and don't share it with anybody. SECRET_KEY = '_g-js)o8z#8=9pr1&05h^1_#)91sbo-)g^(*=-+epxmt4kc9m#' + +# example password validation +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + 'OPTIONS': {'min_length': 8} + } +] + + # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', @@ -118,8 +131,8 @@ 'django.contrib.admin', 'django.contrib.admindocs', 'guardian', - 'south', 'userena', + 'easy_thumbnails', 'userena.contrib.umessages', 'profiles', ) diff --git a/demo/demo/static/css/master.css b/demo/demo/static/css/master.css index b935a8d8..463b4035 100644 --- a/demo/demo/static/css/master.css +++ b/demo/demo/static/css/master.css @@ -760,6 +760,13 @@ div#lang_form input[type=submit] { } +form p + ul { + margin-top: 1em; + font-size: 0.7em; + font-family: 'Droid Sans', helvetica, arial, Geneva, sans-serif; + color: #999; + text-shadow: #ffffff 1px 1px 0; +} /* notifications ................................... */ diff --git a/userena/compat.py b/userena/compat.py index 0f59a1fe..d73b7214 100644 --- a/userena/compat.py +++ b/userena/compat.py @@ -60,3 +60,18 @@ def make_options(options): else: def make_options(options): return () + + +try: + from django.contrib.auth.password_validation import ( + validate_password, + password_validators_help_text_html, + ) + +except (ImportError, AttributeError): + # Password validation is not available for Django < 1.9.3 + def get_password_validators(value): + return None + + def password_validators_help_text_html(): + return None diff --git a/userena/forms.py b/userena/forms.py index dff9c0bf..3e7ed926 100644 --- a/userena/forms.py +++ b/userena/forms.py @@ -1,14 +1,18 @@ #encoding:utf-8 from __future__ import unicode_literals - from django import forms from django.contrib.auth import get_user_model +from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ from django.contrib.auth import authenticate from userena import settings as userena_settings from userena.models import UserenaSignup from userena.utils import get_profile_model +from userena.compat import ( + validate_password, + password_validators_help_text_html +) from hashlib import sha1 import random @@ -40,7 +44,9 @@ class SignupForm(forms.Form): label=_("Email")) password1 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False), - label=_("Create password")) + label=_("Create password"), + validators=[validate_password], + help_text=mark_safe(password_validators_help_text_html())) password2 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False), label=_("Repeat password")) diff --git a/userena/templates/userena/signup_form.html b/userena/templates/userena/signup_form.html index e41083bc..198b562d 100644 --- a/userena/templates/userena/signup_form.html +++ b/userena/templates/userena/signup_form.html @@ -18,8 +18,9 @@

{% else %}

- {{ field.label_tag }} + {{ field.label_tag }} {{ field }} + {{ field.help_text }}

{% endif %} {% endfor %}