Skip to content

Commit 3ae9cc6

Browse files
committed
send requests with auth token
1 parent 83d35a0 commit 3ae9cc6

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

public/js/script.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ function performLfmRequest(url, parameter, type) {
254254

255255
return $.ajax({
256256
type: 'GET',
257+
beforeSend: function(request) {
258+
request.setRequestHeader("Authorization", 'Bearer ' + getUrlParam('token'));
259+
},
257260
dataType: type || 'text',
258261
url: lfm_route + '/' + url,
259262
data: data,
@@ -439,13 +442,13 @@ function move(item) {
439442
notImp();
440443
}
441444

442-
function use(item) {
443-
function getUrlParam(paramName) {
444-
var reParam = new RegExp('(?:[\?&]|&)' + paramName + '=([^&]+)', 'i');
445-
var match = window.location.search.match(reParam);
446-
return ( match && match.length > 1 ) ? match[1] : null;
447-
}
445+
function getUrlParam(paramName) {
446+
var reParam = new RegExp('(?:[\?&]|&)' + paramName + '=([^&]+)', 'i');
447+
var match = window.location.search.match(reParam);
448+
return ( match && match.length > 1 ) ? match[1] : null;
449+
}
448450

451+
function use(item) {
449452
function useTinymce3(url) {
450453
var win = tinyMCEPopup.getWindowArg("window");
451454
win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = url;

src/views/index.blade.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@
268268
}
269269
});
270270
},
271+
headers: {
272+
'Authorization': 'Bearer {{ request('token') }}'
273+
},
271274
acceptedFiles: "{{ implode(',', $helper->availableMimeTypes()) }}",
272275
maxFilesize: ({{ $helper->maxUploadSize() }} / 1000)
273276
}

0 commit comments

Comments
 (0)