Skip to content

Commit

Permalink
fixes pinax#266 settings.AUTH_PASSWORD_VALIDATORS ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegalletti committed Sep 8, 2017
1 parent 50008c7 commit 9eb090e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions account/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
except ImportError:
from django.urls import resolve, reverse, NoReverseMatch # noqa

if django.VERSION >= (1, 9, 0):
from django.contrib.auth.password_validation import validate_password
else:
def validate_password(password, user=None, password_validators=None):
pass


def is_authenticated(user):
if django.VERSION >= (1, 10):
Expand Down
6 changes: 6 additions & 0 deletions account/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import re

from .compat import validate_password

try:
from collections import OrderedDict
except ImportError:
Expand Down Expand Up @@ -88,6 +90,10 @@ def clean(self):
if "password" in self.cleaned_data and "password_confirm" in self.cleaned_data:
if self.cleaned_data["password"] != self.cleaned_data["password_confirm"]:
raise forms.ValidationError(_("You must type the same password each time."))
dummy_user = get_user_model()
dummy_user.username = self.cleaned_data.get("username")
dummy_user.email = self.cleaned_data.get("email")
validate_password(self.cleaned_data["password"], dummy_user)
return self.cleaned_data


Expand Down

0 comments on commit 9eb090e

Please sign in to comment.