Ticket #159: ticket-159-circular-logout.patch
File ticket-159-circular-logout.patch, 2.7 KB (added by , 13 years ago) |
---|
-
django/contrib/admin/sites.py
diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py old mode 100644 new mode 100755 index 83a0869..304df5c
a b from django.utils.text import capfirst 14 14 from django.utils.translation import ugettext as _ 15 15 from django.views.decorators.cache import never_cache 16 16 from django.conf import settings 17 from django.http import HttpResponseRedirect 18 17 19 18 20 LOGIN_FORM_KEY = 'this_is_the_login_form' 19 21 … … class AdminSite(object): 188 190 """ 189 191 def inner(request, *args, **kwargs): 190 192 if not self.has_permission(request): 193 if request.path.endswith(reverse('admin:logout')): 194 return HttpResponseRedirect(reverse('admin:index')) 191 195 return self.login(request) 192 196 return view(request, *args, **kwargs) 193 197 if not cacheable: -
tests/regressiontests/admin_views/tests.py
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py old mode 100644 new mode 100755 index 6037c2b..4ef3e9d
a b class AdminCustomSaveRelatedTests(TestCase): 3351 3351 3352 3352 self.assertEqual('Josh Stone', Parent.objects.latest('id').name) 3353 3353 self.assertEqual([u'Catherine Stone', u'Paul Stone'], children_names) 3354 3355 class AdminViewLogoutTest(TestCase): 3356 urls = "regressiontests.admin_views.urls" 3357 fixtures = ['admin-views-users.xml', ] 3358 3359 def setUp(self): 3360 self.client.login(username='super', password='secret') 3361 3362 def tearDown(self): 3363 self.client.logout() 3364 3365 def test_client_logout_url_can_be_used_to_login(self): 3366 response = self.client.get('/test_admin/admin/logout/') 3367 self.assertEqual(response.status_code, 200) 3368 self.assertEqual(response.template_name, 'registration/logged_out.html') 3369 self.assertEqual(response.request['PATH_INFO'], '/test_admin/admin/logout/') 3370 3371 # we are now logged out - issue a GET request to `/test_admin/admin/logout/` 3372 response = self.client.get('/test_admin/admin/logout/') 3373 self.assertEqual(response.status_code, 302) # we should be redirected to the login page. 3374 3375 response = self.client.get('/test_admin/admin/logout/', follow=True) # follow the redirect and test results. 3376 self.assertEqual(response.status_code, 200) 3377 self.assertEqual(response.template_name, 'admin/login.html') 3378 self.assertEqual(response.request['PATH_INFO'], '/test_admin/admin/') 3379 3380 self.assertTrue( 3381 '<input type="hidden" name="next" value="/test_admin/admin/" />' in response.content)