fusionbox / django-authtools

A custom User model for everybody!
https://django-authtools.readthedocs.org/
BSD 2-Clause "Simplified" License
372 stars 103 forks source link

UserCreationForm doesn't use Django 1.9's password validation #55

Open gavinwahl opened 9 years ago

gavinwahl commented 9 years ago

It needs to call django.contrib.auth.password_validation.validate_password to hook in to https://docs.djangoproject.com/en/dev/topics/auth/passwords/#enabling-password-validation

rockymeza commented 9 years ago

Also, there is some help_text:

https://github.com/django/django/blob/master/django/contrib/auth/forms.py#L272

SpaceK33z commented 8 years ago

When trying to use authtools with Django 1.9 I get the following error:

django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

ERRORS:
<class 'files.admin.UserAdmin'>: (admin.E108) The value of 'list_display[2]' refers to 'name', which is not a callable, an attribute of 'UserAdmin', or an attribute or method on 'auth.User'.

Is this ticket related to that error?

gavinwahl commented 8 years ago

I don't think that's related. Can you open another issue with the value of AUTH_USER_MODEL and files.admin.UserAdmin?

raratiru commented 8 years ago

At first glance, the mechanism without the help text, seems like it will work modifying the clean_password2 in forms.py:

Django method vs authtools method

At second glance, care should be taken for the USERNAME_FIELD which is different in EmailUser and NameUser classes. Except if self.cleaned_data.get('username') automatically fetches the relevant field.

I will give it a try, when I am not at work...

elnygren commented 8 years ago

I am currently using this solution, which should be easy to adapt for authtools

from authtools.forms import UserCreationForm
from django.contrib.auth.password_validation import validate_password

class SignupForm(UserCreationForm):
    class Meta:
        model = User
        fields = [
            'name',
            'email',
            'password1',
            'password2'
        ]

    def clean_password1(self):
        validate_password(self.cleaned_data.get('password1'))
xkill commented 7 years ago

Same problem on Django 1.10.6