Fixed #28513 -- Added POST request support to LogoutView.

This commit is contained in:
hui shang 2017-08-24 21:11:16 +08:00 committed by Tim Graham
parent da0fb5b1ec
commit c0f4c60edd
3 changed files with 13 additions and 0 deletions

View File

@ -133,6 +133,10 @@ class LogoutView(SuccessURLAllowedHostsMixin, TemplateView):
return HttpResponseRedirect(next_page)
return super().dispatch(request, *args, **kwargs)
def post(self, request, *args, **kwargs):
"""Logout may be done via POST."""
return self.get(request, *args, **kwargs)
def get_next_page(self):
if self.next_page is not None:
next_page = resolve_url(self.next_page)

View File

@ -23,3 +23,6 @@ Bugfixes
requires an update to Oracle tables created with Django 1.11.[1-4]. Use the
upgrade script in :ticket:`28451` comment 8 to update sequence and trigger
names to use the pre-1.11 naming scheme.
* Added POST request support to ``LogoutView``, for equivalence with the
function-based ``logout()`` view (:ticket:`28513`).

View File

@ -922,6 +922,12 @@ class LogoutTest(AuthViewsTestCase):
self.assertContains(response, 'Logged out')
self.confirm_logged_out()
def test_logout_with_post(self):
self.login()
response = self.client.post('/logout/')
self.assertContains(response, 'Logged out')
self.confirm_logged_out()
def test_14377(self):
# Bug 14377
self.login()