use new password widget in manager (#25045)

This commit is contained in:
Benjamin Dauvergne 2018-07-20 00:14:51 +02:00
parent 1f6791710e
commit 6c1def8a88
3 changed files with 20 additions and 22 deletions

View File

@ -12,6 +12,7 @@ from django.core.exceptions import ValidationError
from authentic2.compat import get_user_model
from authentic2.passwords import generate_password
from authentic2.utils import send_templated_mail
from authentic2.forms.fields import NewPasswordField, CheckPasswordField
from django_rbac.models import Operation
from django_rbac.utils import get_ou_model, get_role_model, get_permission_model
@ -288,14 +289,11 @@ class UserChangePasswordForm(CssClass, forms.ModelForm):
initial=False,
label=_('Generate new password'),
required=False)
password1 = forms.CharField(
password1 = NewPasswordField(
label=_("Password"),
widget=forms.PasswordInput,
required=False)
password2 = forms.CharField(
password2 = CheckPasswordField(
label=_("Confirmation"),
widget=forms.PasswordInput,
help_text=_("Enter the same password as above, for verification."),
required=False)
send_mail = forms.BooleanField(
initial=True,

View File

@ -44,7 +44,7 @@
{{ field.label_tag }}
{{ field }}
{% if field.help_text %}
<span class="helptext">{{ field.help_text }}</span>
<span class="helptext">{{ field.help_text|safe }}</span>
{% endif %}
{% if field.errors %}
<ul class="errorlist">

View File

@ -148,8 +148,8 @@ def test_manager_stress_create_user(superuser_or_admin, app, mailoutbox):
form.set('first_name', 'John')
form.set('last_name', 'Doe')
form.set('email', 'john.doe@gmail.com')
form.set('password1', 'password')
form.set('password2', 'password')
form.set('password1', 'ABcd1234')
form.set('password2', 'ABcd1234')
form.submit().follow()
app.get('/logout/').form.submit()
assert User.objects.filter(ou_id=new_ou.id).count() == 100
@ -198,8 +198,8 @@ def test_manager_create_user(superuser_or_admin, app, settings):
form.set('first_name', 'John')
form.set('last_name', 'Doe')
form.set('email', 'john.doe@gmail.com')
form.set('password1', 'password')
form.set('password2', 'password')
form.set('password1', 'ABcd1234')
form.set('password2', 'ABcd1234')
response = form.submit().follow()
assert User.objects.filter(ou=ou1).count() == 1
@ -209,8 +209,8 @@ def test_manager_create_user(superuser_or_admin, app, settings):
form.set('first_name', 'John')
form.set('last_name', 'Doe')
form.set('email', 'john.doe@gmail.com')
form.set('password1', 'password')
form.set('password2', 'password')
form.set('password1', 'ABcd1234')
form.set('password2', 'ABcd1234')
response = form.submit().follow()
assert User.objects.filter(ou=ou1).count() == 2
@ -221,8 +221,8 @@ def test_manager_create_user(superuser_or_admin, app, settings):
form.set('first_name', 'John')
form.set('last_name', 'Doe')
form.set('email', 'john.doe@gmail.com')
form.set('password1', 'password')
form.set('password2', 'password')
form.set('password1', 'ABcd1234')
form.set('password2', 'ABcd1234')
response = form.submit().follow()
assert User.objects.filter(ou=ou2).count() == 1
@ -232,8 +232,8 @@ def test_manager_create_user(superuser_or_admin, app, settings):
form.set('first_name', 'John')
form.set('last_name', 'Doe')
form.set('email', 'john.doe@gmail.com')
form.set('password1', 'password')
form.set('password2', 'password')
form.set('password1', 'ABcd1234')
form.set('password2', 'ABcd1234')
response = form.submit()
assert User.objects.filter(ou=ou2).count() == 1
assert 'Email already used' in response
@ -244,8 +244,8 @@ def test_manager_create_user(superuser_or_admin, app, settings):
form.set('first_name', 'Jane')
form.set('last_name', 'Doe')
form.set('email', 'john.doe2@gmail.com')
form.set('password1', 'password')
form.set('password2', 'password')
form.set('password1', 'ABcd1234')
form.set('password2', 'ABcd1234')
response = form.submit().follow()
assert User.objects.filter(ou=ou2).count() == 2
@ -265,15 +265,15 @@ def test_manager_create_user(superuser_or_admin, app, settings):
form.set('first_name', 'John')
form.set('last_name', 'Doe')
form.set('email', 'john.doe@gmail.com')
form.set('password1', 'password')
form.set('password2', 'password')
form.set('password1', 'ABcd1234')
form.set('password2', 'ABcd1234')
response = form.submit()
assert User.objects.filter(ou=ou1).count() == 0
assert 'Email already used' in response
form = response.form
form.set('email', 'john.doe3@gmail.com')
form.set('password1', 'password')
form.set('password2', 'password')
form.set('password1', 'ABcd1234')
form.set('password2', 'ABcd1234')
response = form.submit().follow()
assert User.objects.filter(ou=ou1).count() == 1