Skip to content

fixes #266 settings.AUTH_PASSWORD_VALIDATORS ignored #267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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