Skip to content

Validation no been applied on user creation #25

@patillacode

Description

@patillacode

Hi,

I have managed to make django-passwords for default django admin users, but only when they try to change their password. I don't seem to find a way to make this work when creating a user .

Here is my code:

forms.py

from django.contrib.auth.forms import SetPasswordForm,PasswordChangeForm
from django.utils.translation import ugettext_lazy as _
from passwords.fields import PasswordField

class ValidatingSetPasswordForm(SetPasswordForm):
    new_password2 = PasswordField(label=_("New password confirmation"))

class ValidatingPasswordChangeForm(PasswordChangeForm):
    new_password2 = PasswordField(label=_("New password confirmation"))

As you can see I have been able to override the field new_password2 setting it up as a PasswordField

Then I force those urls to go through my forms, see below:
urls.py

urlpatterns = patterns('',
    url(r'^admin/password_change/$', 'django.contrib.auth.views.password_change',{'password_change_form': ValidatingPasswordChangeForm}),
    url(r'^admin/password_changed/$', 'django.contrib.auth.views.password_change_done'),
    url(r'^admin/password_reset/$', 'django.contrib.auth.views.password_reset'),
    url(r'^admin/password_reset_done/$', 'django.contrib.auth.views.password_reset_done'),
    url(r'^admin/password_reset_complete/$', 'django.contrib.auth.views.password_reset_complete'),
    url(r'^admin/password_reset_confirm/(?P<uidb36>[-\w]+)/(?P<token>[-\w]+)/$','django.contrib.auth.views.password_reset_confirm',{'set_password_form': ValidatingSetPasswordForm}),

    url(r'^admin/', include(admin.site.urls)),
)

What am I missing?

Any help would be highly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions