Projet

Général

Profil

0008-use-new-password-fields-in-registration-form-fixes-2.patch

Benjamin Dauvergne, 20 juillet 2018 15:48

Télécharger (2,78 ko)

Voir les différences:

Subject: [PATCH 8/9] use new password fields in registration form (fixes
 #24439)

 src/authentic2/registration_backend/forms.py |  7 +++----
 tests/test_registration.py                   | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 4 deletions(-)
src/authentic2/registration_backend/forms.py
19 19
from django.core.urlresolvers import reverse
20 20
from django.core.validators import RegexValidator
21 21

  
22
from authentic2.forms.fields import NewPasswordField, CheckPasswordField
22 23
from .. import app_settings, compat, forms, utils, validators, models, middleware, hooks
23 24
from authentic2.a2_rbac.models import OrganizationalUnit
24 25

  
......
115 116

  
116 117

  
117 118
class RegistrationCompletionForm(RegistrationCompletionFormNoPassword):
118
    password1 = CharField(widget=PasswordInput, label=_("Password"),
119
            validators=[validators.validate_password],
120
            help_text=validators.password_help_text())
121
    password2 = CharField(widget=PasswordInput, label=_("Password (again)"))
119
    password1 = NewPasswordField(label=_('Password'))
120
    password2 = CheckPasswordField(label=_("Password (again)"))
122 121

  
123 122
    def clean(self):
124 123
        """
tests/test_registration.py
1 1
# -*- coding: utf-8 -*-
2 2

  
3
import re
3 4
from urlparse import urlparse
4 5

  
5 6
from django.core.urlresolvers import reverse
......
585 586
    response = response.form.submit()
586 587
    assert new_next_url in response.content
587 588

  
589

  
590
def test_registration_activate_passwords_not_equal(app, db, settings, mailoutbox):
591
    settings.LANGUAGE_CODE = 'en-us'
592
    settings.A2_VALIDATE_EMAIL_DOMAIN = can_resolve_dns()
593
    settings.A2_EMAIL_IS_UNIQUE = True
594

  
595
    response = app.get(reverse('registration_register'))
596
    response.form.set('email', 'testbot@entrouvert.com')
597
    response = response.form.submit()
598
    response = response.follow()
599
    link = get_link_from_mail(mailoutbox[0])
600
    response = app.get(link)
601
    response.form.set('password1', 'azerty12AZ')
602
    response.form.set('password2', 'AAAazerty12AZ')
603
    response = response.form.submit()
604
    assert "The two password fields didn't match." in response.content
588
-