use new password fields in registration form (fixes #24439)

This commit is contained in:
Benjamin Dauvergne 2018-07-19 16:12:59 +02:00
parent f36b480419
commit c46822af58
2 changed files with 20 additions and 4 deletions

View File

@ -19,6 +19,7 @@ from django.template.loader import render_to_string
from django.core.urlresolvers import reverse
from django.core.validators import RegexValidator
from authentic2.forms.fields import NewPasswordField, CheckPasswordField
from .. import app_settings, compat, forms, utils, validators, models, middleware, hooks
from authentic2.a2_rbac.models import OrganizationalUnit
@ -115,10 +116,8 @@ class RegistrationCompletionFormNoPassword(forms.BaseUserForm):
class RegistrationCompletionForm(RegistrationCompletionFormNoPassword):
password1 = CharField(widget=PasswordInput, label=_("Password"),
validators=[validators.validate_password],
help_text=validators.password_help_text())
password2 = CharField(widget=PasswordInput, label=_("Password (again)"))
password1 = NewPasswordField(label=_('Password'))
password2 = CheckPasswordField(label=_("Password (again)"))
def clean(self):
"""

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import re
from urlparse import urlparse
from django.core.urlresolvers import reverse
@ -585,3 +586,19 @@ def test_registration_redirect_tuple(app, db, settings, mailoutbox, external_red
response = response.form.submit()
assert new_next_url in response.content
def test_registration_activate_passwords_not_equal(app, db, settings, mailoutbox):
settings.LANGUAGE_CODE = 'en-us'
settings.A2_VALIDATE_EMAIL_DOMAIN = can_resolve_dns()
settings.A2_EMAIL_IS_UNIQUE = True
response = app.get(reverse('registration_register'))
response.form.set('email', 'testbot@entrouvert.com')
response = response.form.submit()
response = response.follow()
link = get_link_from_mail(mailoutbox[0])
response = app.get(link)
response.form.set('password1', 'azerty12AZ')
response.form.set('password2', 'AAAazerty12AZ')
response = response.form.submit()
assert "The two password fields didn't match." in response.content