mirror of
https://github.com/pinry/pinry.git
synced 2025-11-14 00:55:43 +01:00
14 lines
379 B
Python
14 lines
379 B
Python
from django.middleware.csrf import get_token
|
|
from django.utils.deprecation import MiddlewareMixin
|
|
|
|
|
|
class ForceCSRFCookieMiddleware(MiddlewareMixin):
|
|
|
|
def process_request(self, request):
|
|
if "CSRF_TOKEN" not in request.META:
|
|
get_token(request)
|
|
else:
|
|
if request.method != "GET":
|
|
get_token(request)
|
|
return
|