Add CSRF check for task and project files upload
This commit is contained in:
4
assets/js/app.min.js
vendored
4
assets/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -29,7 +29,7 @@ KB.component('file-upload', function (containerElement, options) {
|
||||
currentFileIndex++;
|
||||
|
||||
if (currentFileIndex < files.length) {
|
||||
KB.http.uploadFile(options.url, files[currentFileIndex], onProgress, onComplete, onError, onServerError);
|
||||
KB.http.uploadFile(options.url, files[currentFileIndex], options.csrf, onProgress, onComplete, onError, onServerError);
|
||||
} else {
|
||||
KB.trigger('modal.stop');
|
||||
KB.trigger('modal.hide');
|
||||
@@ -92,7 +92,7 @@ KB.component('file-upload', function (containerElement, options) {
|
||||
|
||||
function uploadFiles() {
|
||||
if (files.length > 0) {
|
||||
KB.http.uploadFile(options.url, files[currentFileIndex], onProgress, onComplete, onError, onServerError);
|
||||
KB.http.uploadFile(options.url, files[currentFileIndex], options.csrf, onProgress, onComplete, onError, onServerError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,9 +83,10 @@ KB.http.postForm = function (url, formElement) {
|
||||
return (new KB.http.request('POST', url, {}, formData)).execute();
|
||||
};
|
||||
|
||||
KB.http.uploadFile = function (url, file, onProgress, onComplete, onError, onServerError) {
|
||||
KB.http.uploadFile = function (url, file, csrf, onProgress, onComplete, onError, onServerError) {
|
||||
var fd = new FormData();
|
||||
fd.append('files[]', file);
|
||||
fd.append('csrf_token', csrf);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.upload.addEventListener('progress', onProgress);
|
||||
|
||||
Reference in New Issue
Block a user