0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 18:50:27 +01:00

FIX: add csrf token to all wizard ajax requests in dev (#129)

* FIX: add csrf token to all wizard ajax requests in dev

* fix formatting

* simplified code

* Update field.rb
Dieser Commit ist enthalten in:
Faizaan Gagan 2021-07-01 11:25:31 +05:30 committet von GitHub
Ursprung 0bd4dbd08b
Commit d8f6f00e60
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -26,7 +26,11 @@ export default {
const setDefaultOwner = requirejs("discourse-common/lib/get-owner")
.setDefaultOwner;
const messageBus = requirejs("message-bus-client").default;
const getToken = requirejs("wizard/lib/ajax").getToken;
const setEnvironment = requirejs("discourse-common/config/environment")
.setEnvironment;
const isDevelopment = requirejs("discourse-common/config/environment")
.isDevelopment;
const container = app.__container__;
Discourse.Model = EmberObject.extend();
Discourse.__container__ = container;
@ -89,6 +93,7 @@ export default {
const session = container.lookup("session:main");
const setupData = document.getElementById("data-discourse-setup").dataset;
session.set("highlightJsPath", setupData.highlightJsPath);
setEnvironment(setupData.environment);
Router.reopen({
rootURL: getUrl("/w/"),
@ -107,5 +112,11 @@ export default {
},
model() {},
});
$.ajaxPrefilter(function (_, __, jqXHR) {
if (isDevelopment()) {
jqXHR.setRequestHeader("X-CSRF-Token", getToken());
}
});
},
};