Ticket #8127: csrf_check_ajax_requests_too.diff
File csrf_check_ajax_requests_too.diff, 890 bytes (added by , 16 years ago) |
---|
-
middleware.py
51 51 52 52 csrf_token = _make_token(session_id) 53 53 # check incoming token 54 try: 55 request_csrf_token = request.POST['csrfmiddlewaretoken'] 56 except KeyError: 57 return HttpResponseForbidden(_ERROR_MSG) 54 if request.is_ajax(): 55 request_csrf_token = request.META.get('HTTP_X_CSRFMIDDLEWARETOKEN') 56 else: 57 try: 58 request_csrf_token = request.POST['csrfmiddlewaretoken'] 59 except KeyError: 60 return HttpResponseForbidden(_ERROR_MSG) 58 61 59 62 if request_csrf_token != csrf_token: 60 63 return HttpResponseForbidden(_ERROR_MSG)