1
0
Fork 0
forked from OpenNeo/impress
impress/app/assets/javascripts/ajax_auth.js

21 lines
494 B
JavaScript
Raw Permalink Normal View History

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