django-user-accounts
django-user-accounts copied to clipboard
fixes #266 settings.AUTH_PASSWORD_VALIDATORS ignored
Would love to see the one merged 😃
@brosner could you take a look at this?
@davidegalletti I think this is a nice attempt but only covers signup password validation. It would also be nice to see change password and password reset management as well. Still appreciative either way.
Would love to see this get attention. For now I've been overriding the forms.py from within my project for views requiring additional validations, and implementing my own validations manually...
*forms.py*
from django.utils.translation import ugettext_lazy as _
class ChangePasswordForm(account.forms.ChangePasswordForm):
def clean_password_new_confirm(self):
if "password_new" in self.cleaned_data and "password_new_confirm" in self.cleaned_data:
if self.cleaned_data["password_new"] != self.cleaned_data["password_new_confirm"]:
raise forms.ValidationError(_("You must type the same password each time."))
if len(self.cleaned_data["password_new"]) < 10:
raise forms.ValidationError(_("Password must be at least 10 digits."))
return self.cleaned_data["password_new_confirm"]
*views.py*
from .forms import ChangePasswordForm
class ChangePasswordView(account.views.ChangePasswordView):
form_class = ChangePasswordForm
pass
*urls.py*
path("account/password/", views.ChangePasswordView.as_view(), name="account_password"),
@davidegalletti - can you fix conflicts and remove the check on Django version since projects should no longer be using DJango 1 or even Django 2 for that matter. I will merge when you provide the changes.