diff --git a/main/webapp/modules/core/scripts/index.js b/main/webapp/modules/core/scripts/index.js index 1a22bfba2..f4aad9440 100644 --- a/main/webapp/modules/core/scripts/index.js +++ b/main/webapp/modules/core/scripts/index.js @@ -37,6 +37,26 @@ var Refine = { actionAreas: [] }; +Refine.wrapCSRF = function(onCSRF) { + $.get( + "command/core/get-csrf-token", + {}, + function(response) { + onCSRF(response['token']); + }, + "json" + ); +}; + +Refine.postCSRF = function(url, data, success, dataType) { + Refine.wrapCSRF(function(token) { + var fullData = data || {}; + data['csrf_token'] = token; + $.post(url, fulldata, success, dataType); + }); +}; + + var lang = (navigator.language|| navigator.userLanguage).split("-")[0]; var dictionary = ""; $.ajax({ diff --git a/main/webapp/modules/core/scripts/index/default-importing-controller/controller.js b/main/webapp/modules/core/scripts/index/default-importing-controller/controller.js index 60d8d1ac4..cb749bb79 100644 --- a/main/webapp/modules/core/scripts/index/default-importing-controller/controller.js +++ b/main/webapp/modules/core/scripts/index/default-importing-controller/controller.js @@ -187,7 +187,7 @@ Refine.DefaultImportingController.prototype._ensureFormatParserUIHasInitializati $.post( "command/core/importing-controller?" + $.param({ "controller": "core/default-importing-controller", - "jobID": this._jobID, + "jobID": self._jobID, "subCommand": "initialize-parser-ui", "format": format, "csrf_token": token @@ -219,12 +219,12 @@ Refine.DefaultImportingController.prototype.updateFormatAndOptions = function(op $.post( "command/core/importing-controller?" + $.param({ "controller": "core/default-importing-controller", - "jobID": this._jobID, + "jobID": self._jobID, "subCommand": "update-format-and-options", "csrf_token": token }), { - "format" : this._format, + "format" : self._format, "options" : JSON.stringify(options) }, function(o) { @@ -297,12 +297,12 @@ Refine.DefaultImportingController.prototype._createProject = function() { $.post( "command/core/importing-controller?" + $.param({ "controller": "core/default-importing-controller", - "jobID": this._jobID, + "jobID": self._jobID, "subCommand": "create-project", "csrf_token": token }), { - "format" : this._format, + "format" : self._format, "options" : JSON.stringify(options) }, function(o) {