Skip to content

Commit 37ee470

Browse files
authored
[5.1] ModalSelect add token to the URLs (joomla#43745)
1 parent cd7b511 commit 37ee470

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

build/media_source/system/js/fields/modal-content-select-field.es6.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,24 @@ const setupField = (container) => {
113113
const action = button.dataset.buttonAction;
114114
const dialogConfig = button.dataset.modalConfig ? JSON.parse(button.dataset.modalConfig) : {};
115115
const keyName = container.dataset.keyName || 'id';
116+
const token = Joomla.getOptions('csrf.token', '');
116117

117118
// Handle requested action
118119
let handle;
119120
switch (action) {
120121
case 'select':
121-
case 'create':
122+
case 'create': {
123+
const url = dialogConfig.src.indexOf('http') === 0 ? new URL(dialogConfig.src) : new URL(dialogConfig.src, window.location.origin);
124+
url.searchParams.set(token, '1');
125+
dialogConfig.src = url.toString();
122126
handle = doSelect(inputValue, inputTitle, dialogConfig);
123127
break;
128+
}
124129
case 'edit': {
125130
// Update current value in the URL
126131
const url = dialogConfig.src.indexOf('http') === 0 ? new URL(dialogConfig.src) : new URL(dialogConfig.src, window.location.origin);
127132
url.searchParams.set(keyName, inputValue.value);
133+
url.searchParams.set(token, '1');
128134
dialogConfig.src = url.toString();
129135

130136
handle = doSelect(inputValue, inputTitle, dialogConfig);

0 commit comments

Comments
 (0)