diff --git a/django/contrib/admin/forms.py b/django/contrib/admin/forms.py
index f1e7076..70e55f8 100644
a
|
b
|
class AdminAuthenticationForm(AuthenticationForm):
|
29 | 29 | raise forms.ValidationError(message) |
30 | 30 | elif not self.user_cache.is_active or not self.user_cache.is_staff: |
31 | 31 | raise forms.ValidationError(message) |
32 | | self.check_for_test_cookie() |
33 | 32 | return self.cleaned_data |
diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
index b44bc8b..e14119c 100644
a
|
b
|
class AuthenticationForm(forms.Form):
|
150 | 150 | error_messages = { |
151 | 151 | 'invalid_login': _("Please enter a correct username and password. " |
152 | 152 | "Note that both fields are case-sensitive."), |
153 | | 'no_cookies': _("Your Web browser doesn't appear to have cookies " |
154 | | "enabled. Cookies are required for logging in."), |
155 | 153 | 'inactive': _("This account is inactive."), |
156 | 154 | } |
157 | 155 | |
158 | 156 | def __init__(self, request=None, *args, **kwargs): |
159 | 157 | """ |
160 | | If request is passed in, the form will validate that cookies are |
161 | | enabled. Note that the request (a HttpRequest object) must have set a |
162 | | cookie with the key TEST_COOKIE_NAME and value TEST_COOKIE_VALUE before |
163 | | running this validation. |
| 158 | The 'request' parameter was historically set to test for cookie |
| 159 | support (now obsoleted by csrf checks). It has been kept for potential |
| 160 | subclasses usage. |
164 | 161 | """ |
165 | 162 | self.request = request |
166 | 163 | self.user_cache = None |
… |
… |
class AuthenticationForm(forms.Form):
|
183 | 180 | self.error_messages['invalid_login']) |
184 | 181 | elif not self.user_cache.is_active: |
185 | 182 | raise forms.ValidationError(self.error_messages['inactive']) |
186 | | self.check_for_test_cookie() |
187 | 183 | return self.cleaned_data |
188 | 184 | |
189 | 185 | def check_for_test_cookie(self): |
190 | | if self.request and not self.request.session.test_cookie_worked(): |
191 | | raise forms.ValidationError(self.error_messages['no_cookies']) |
| 186 | warnings.warn("check_for_test_cookie is deprecated; but don't forget to " |
| 187 | "CRSF-protect your login view.", PendingDeprecationWarning) |
192 | 188 | |
193 | 189 | def get_user_id(self): |
194 | 190 | if self.user_cache: |
diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
index 2562a63..1dc204d 100644
a
|
b
|
def login(request, template_name='registration/login.html',
|
35 | 35 | redirect_to = request.REQUEST.get(redirect_field_name, '') |
36 | 36 | |
37 | 37 | if request.method == "POST": |
38 | | form = authentication_form(data=request.POST) |
| 38 | form = authentication_form(request, data=request.POST) |
39 | 39 | if form.is_valid(): |
40 | 40 | # Use default setting if redirect_to is empty |
41 | 41 | if not redirect_to: |
… |
… |
def login(request, template_name='registration/login.html',
|
58 | 58 | else: |
59 | 59 | form = authentication_form(request) |
60 | 60 | |
61 | | request.session.set_test_cookie() |
62 | | |
63 | 61 | current_site = get_current_site(request) |
64 | 62 | |
65 | 63 | context = { |