mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Refs #15619 -- Removed support for logging out via GET requests.
Per deprecation timeline.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import warnings
|
||||
from urllib.parse import urlparse, urlunparse
|
||||
|
||||
from django.conf import settings
|
||||
@@ -22,7 +21,6 @@ from django.http import HttpResponseRedirect, QueryDict
|
||||
from django.shortcuts import resolve_url
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.utils.deprecation import RemovedInDjango50Warning
|
||||
from django.utils.http import url_has_allowed_host_and_scheme, urlsafe_base64_decode
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.decorators.cache import never_cache
|
||||
@@ -128,25 +126,15 @@ class LogoutView(RedirectURLMixin, TemplateView):
|
||||
Log out the user and display the 'You are logged out' message.
|
||||
"""
|
||||
|
||||
# RemovedInDjango50Warning: when the deprecation ends, remove "get" and
|
||||
# "head" from http_method_names.
|
||||
http_method_names = ["get", "head", "post", "options"]
|
||||
http_method_names = ["post", "options"]
|
||||
template_name = "registration/logged_out.html"
|
||||
extra_context = None
|
||||
|
||||
# RemovedInDjango50Warning: when the deprecation ends, move
|
||||
# @method_decorator(csrf_protect) from post() to dispatch().
|
||||
@method_decorator(csrf_protect)
|
||||
@method_decorator(never_cache)
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if request.method.lower() == "get":
|
||||
warnings.warn(
|
||||
"Log out via GET requests is deprecated and will be removed in Django "
|
||||
"5.0. Use POST requests for logging out.",
|
||||
RemovedInDjango50Warning,
|
||||
)
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
@method_decorator(csrf_protect)
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""Logout may be done via POST."""
|
||||
auth_logout(request)
|
||||
@@ -156,9 +144,6 @@ class LogoutView(RedirectURLMixin, TemplateView):
|
||||
return HttpResponseRedirect(redirect_to)
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
# RemovedInDjango50Warning.
|
||||
get = post
|
||||
|
||||
def get_default_redirect_url(self):
|
||||
"""Return the default redirect URL."""
|
||||
if self.next_page:
|
||||
|
||||
Reference in New Issue
Block a user