Projet

Général

Profil

0004-password-use-login-form-customization-fields-51363.patch

Valentin Deniaud, 27 juillet 2022 10:57

Télécharger (3,34 ko)

Voir les différences:

Subject: [PATCH 4/4] password: use login form customization fields (#51363)

 src/authentic2/apps/authenticators/forms.py                | 2 +-
 .../templates/authentic2/login_password_form.html          | 4 ++++
 src/authentic2/views.py                                    | 1 +
 tests/test_login.py                                        | 7 +++++++
 tests/test_manager_authenticators.py                       | 1 -
 5 files changed, 13 insertions(+), 2 deletions(-)
src/authentic2/apps/authenticators/forms.py
70 70
class LoginPasswordAuthenticatorEditForm(AuthenticatorFormMixin, forms.ModelForm):
71 71
    class Meta:
72 72
        model = LoginPasswordAuthenticator
73
        exclude = ('name', 'slug', 'ou')
73
        exclude = ('name', 'slug', 'ou', 'button_label')
src/authentic2/templates/authentic2/login_password_form.html
3 3
{% block login %}
4 4

  
5 5
{% block form %}
6
{% if authenticator.button_description %}
7
<p>{{ authenticator.button_description }}</p>
8
{% endif %}
9

  
6 10
<div>
7 11
<form method="post" id="login-password-form" class="pk-mark-optional-fields">
8 12
{% csrf_token %}
src/authentic2/views.py
763 763
        form.fields['username'].label = app_settings.A2_USERNAME_LABEL
764 764
    is_secure = request.is_secure
765 765
    context['submit_name'] = 'login-password-submit'
766
    context['authenticator'] = authenticator
766 767
    if is_post:
767 768
        csrf_token_check(request, form)
768 769
        if form.is_valid():
tests/test_login.py
364 364
    assert_event('user.login', user=simple_user, session=app.session, how='token')
365 365

  
366 366

  
367
def test_button_description(app, db):
368
    LoginPasswordAuthenticator.objects.update(button_description='This is a test.')
369

  
370
    response = app.get('/login/')
371
    assert 'This is a test.' in response.text
372

  
373

  
367 374
def test_password_authenticator_data_migration(migration, settings):
368 375
    app = 'authenticators'
369 376
    migrate_from = [(app, '0002_loginpasswordauthenticator')]
tests/test_manager_authenticators.py
57 57
        'csrfmiddlewaretoken',
58 58
        'show_condition',
59 59
        'button_description',
60
        'button_label',
61 60
        'remember_me',
62 61
        'include_ou_selector',
63 62
        None,
64
-