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.
|
||||
export default {
|
||||
name: "csrf-token",
|
||||
initialize: function(container) {
|
||||
var session = container.lookup("session:main");
|
||||
initialize(container) {
|
||||
const session = container.lookup("session:main");
|
||||
const csrfToken = $("meta[name=csrf-token]").attr("content");
|
||||
|
||||
// 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) {
|
||||
if (!options.crossDomain) {
|
||||
xhr.setRequestHeader("X-CSRF-Token", session.get("csrfToken"));
|
||||
xhr.setRequestHeader("X-CSRF-Token", csrfToken);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue