forked from OpenNeo/impress
Emi Matchu
95ff69ee9a
The motivation is that I'm about to change one of them to remove a reference to an old placeholder library, so I want that change to be clear!
20 lines
494 B
JavaScript
20 lines
494 B
JavaScript
(function () {
|
|
var CSRFProtection;
|
|
var token = $('meta[name="csrf-token"]').attr("content");
|
|
if (token) {
|
|
CSRFProtection = function (xhr, settings) {
|
|
var sendToken =
|
|
typeof settings.useCSRFProtection === "undefined" || // default to true
|
|
settings.useCSRFProtection;
|
|
if (sendToken) {
|
|
xhr.setRequestHeader("X-CSRF-Token", token);
|
|
}
|
|
};
|
|
} else {
|
|
CSRFProtection = $.noop;
|
|
}
|
|
|
|
$.ajaxSetup({
|
|
beforeSend: CSRFProtection,
|
|
});
|
|
})();
|