0001-forms-authn-define-explicit-fields-order-72430.patch
src/authentic2/forms/authentication.py | ||
---|---|---|
59 | 59 |
queryset=OU.objects.all(), |
60 | 60 |
) |
61 | 61 | |
62 |
field_order = ['username', 'phone', 'password', 'ou', 'remember_me'] |
|
63 | ||
62 | 64 |
def __init__(self, *args, **kwargs): |
63 | 65 |
preferred_ous = kwargs.pop('preferred_ous', []) |
64 | 66 |
self.authenticator = kwargs.pop('authenticator') |
tests/test_login.py | ||
---|---|---|
21 | 21 | |
22 | 22 |
from authentic2 import models |
23 | 23 |
from authentic2.apps.authenticators.models import LoginPasswordAuthenticator |
24 |
from authentic2.utils.misc import get_token_login_url |
|
24 |
from authentic2.utils.misc import get_authenticators, get_token_login_url
|
|
25 | 25 | |
26 | 26 |
from .utils import assert_event, login, set_service |
27 | 27 | |
... | ... | |
96 | 96 |
assert response.pyquery('span.optional') |
97 | 97 | |
98 | 98 | |
99 |
def test_login_form_fields_order(db, app, settings, ou1, ou2): |
|
100 |
response = app.get('/login/') |
|
101 |
assert list(response.form.fields.keys()) == [ |
|
102 |
'csrfmiddlewaretoken', |
|
103 |
'username', |
|
104 |
'password', |
|
105 |
'login-password-submit', |
|
106 |
] |
|
107 | ||
108 |
settings.A2_ACCEPT_PHONE_AUTHENTICATION = True |
|
109 | ||
110 |
response = app.get('/login/') |
|
111 |
assert list(response.form.fields.keys()) == [ |
|
112 |
'csrfmiddlewaretoken', |
|
113 |
'username', |
|
114 |
'phone_0', |
|
115 |
'phone_1', |
|
116 |
'password', |
|
117 |
'login-password-submit', |
|
118 |
] |
|
119 | ||
120 |
authn = get_authenticators()[0] |
|
121 |
authn.remember_me = True |
|
122 |
authn.include_ou_selector = True |
|
123 |
authn.save() |
|
124 | ||
125 |
response = app.get('/login/') |
|
126 |
assert list(response.form.fields.keys()) == [ |
|
127 |
'csrfmiddlewaretoken', |
|
128 |
'username', |
|
129 |
'phone_0', |
|
130 |
'phone_1', |
|
131 |
'password', |
|
132 |
'ou', |
|
133 |
'remember_me', |
|
134 |
'login-password-submit', |
|
135 |
] |
|
136 | ||
137 | ||
99 | 138 |
def test_login_inactive_user(db, app): |
100 | 139 |
user1 = User.objects.create(username='john.doe') |
101 | 140 |
user1.set_password('john.doe') |
102 |
- |