Explorar el Código

[core] Add csrf token in non-jQuery requests

Ivan Orlov hace 11 años
padre
commit
1f54b8b
Se han modificado 1 ficheros con 6 adiciones y 7 borrados
  1. 6 7
      desktop/core/src/desktop/templates/common_header.mako

+ 6 - 7
desktop/core/src/desktop/templates/common_header.mako

@@ -181,13 +181,12 @@ from django.utils.translation import ugettext as _
         // these HTTP methods do not require CSRF protection
         return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
       }
-      $.ajaxSetup({
-        beforeSend: function(xhr, settings) {
-          if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
-            xhr.setRequestHeader("X-CSRFToken", csrftoken);
-          }
-        }
-      });
+
+      var xrhsend = XMLHttpRequest.prototype.send;
+      XMLHttpRequest.prototype.send = function(data) {
+        this.setRequestHeader('X-CSRFToken', csrftoken);
+        return xrhsend.apply(this, arguments);
+      }
       /////
 
       // prevents framebusting and clickjacking