2012-01-26 11:30:53 -08:00
|
|
|
(function () {
|
2024-09-09 16:10:45 -07:00
|
|
|
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;
|
|
|
|
}
|
2012-01-26 11:30:53 -08:00
|
|
|
|
2024-09-09 16:10:45 -07:00
|
|
|
$.ajaxSetup({
|
|
|
|
beforeSend: CSRFProtection,
|
|
|
|
});
|
2012-01-26 11:30:53 -08:00
|
|
|
})();
|