Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 09:20:29 +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:
Ursprung
0bd4dbd08b
Commit
d8f6f00e60
1 geänderte Dateien mit 12 neuen und 1 gelöschten Zeilen
|
@ -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());
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
Laden …
In neuem Issue referenzieren