DEV: attempts to prevent session object to be retain in csrf init (#7743)
This commit is contained in:
parent
c407e32368
commit
62c56b6e59
|
@ -1,15 +1,16 @@
|
||||||
// Append our CSRF token to AJAX requests when necessary.
|
// Append our CSRF token to AJAX requests when necessary.
|
||||||
export default {
|
export default {
|
||||||
name: "csrf-token",
|
name: "csrf-token",
|
||||||
initialize: function(container) {
|
initialize(container) {
|
||||||
var session = container.lookup("session:main");
|
const session = container.lookup("session:main");
|
||||||
|
const csrfToken = $("meta[name=csrf-token]").attr("content");
|
||||||
|
|
||||||
// Add a CSRF token to all AJAX requests
|
// Add a CSRF token to all AJAX requests
|
||||||
session.set("csrfToken", $("meta[name=csrf-token]").attr("content"));
|
session.set("csrfToken", csrfToken);
|
||||||
|
|
||||||
$.ajaxPrefilter(function(options, originalOptions, xhr) {
|
$.ajaxPrefilter(function(options, originalOptions, xhr) {
|
||||||
if (!options.crossDomain) {
|
if (!options.crossDomain) {
|
||||||
xhr.setRequestHeader("X-CSRF-Token", session.get("csrfToken"));
|
xhr.setRequestHeader("X-CSRF-Token", csrfToken);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue