From 0cb801451031749bee80d6ced31d1d5fc2c1fed5 Mon Sep 17 00:00:00 2001 From: Protsiv Andrey Date: Fri, 19 Feb 2021 10:22:00 +0200 Subject: [PATCH] add Authorization token to Dropzone uploadForm only if it present in url --- src/views/index.blade.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/views/index.blade.php b/src/views/index.blade.php index f6e0939b..0eb331b3 100644 --- a/src/views/index.blade.php +++ b/src/views/index.blade.php @@ -281,12 +281,16 @@ } }); }, - headers: { - 'Authorization': 'Bearer ' + getUrlParam('token') - }, acceptedFiles: "{{ implode(',', $helper->availableMimeTypes()) }}", maxFilesize: ({{ $helper->maxUploadSize() }} / 1000) } + + var token = getUrlParam('token'); + if (token !== null) { + Dropzone.options.uploadForm.headers = { + 'Authorization': 'Bearer ' + token + }; + }