add optional prefix to url
This commit is contained in:
@@ -184,7 +184,7 @@
|
||||
formCreateUser.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const fd = new FormData(formCreateUser);
|
||||
const res = await fetch('/editor/admin/users', { method: 'POST', headers: { 'X-CSRF-Token': getCSRF() }, body: fd });
|
||||
const res = await fetch(window.prefix('/editor/admin/users'), { method: 'POST', headers: { 'X-CSRF-Token': getCSRF() }, body: fd });
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (res.ok && data.success) { showNotification('User created', 'success'); window.location.reload(); }
|
||||
else { showNotification('Create user failed: ' + (data.error || res.statusText), 'error'); }
|
||||
@@ -200,7 +200,7 @@
|
||||
if (!id) return;
|
||||
if (username === 'admin') { showNotification('Cannot delete default admin user', 'error'); return; }
|
||||
if (!confirm('Delete user ' + username + ' ?')) return;
|
||||
const res = await fetch('/editor/admin/users/' + encodeURIComponent(id), { method: 'DELETE', headers: { 'X-CSRF-Token': getCSRF() } });
|
||||
const res = await fetch(window.prefix('/editor/admin/users/' + encodeURIComponent(id)), { method: 'DELETE', headers: { 'X-CSRF-Token': getCSRF() } });
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (res.ok && data.success) { showNotification('User deleted', 'success'); window.location.reload(); }
|
||||
else { showNotification('Delete user failed: ' + (data.error || res.statusText), 'error'); }
|
||||
@@ -216,7 +216,7 @@
|
||||
const active = action === 'user-activate' ? '1' : '0';
|
||||
const fd = new FormData();
|
||||
fd.set('active', active);
|
||||
const res = await fetch('/editor/admin/users/' + encodeURIComponent(id) + '/active', { method: 'POST', headers: { 'X-CSRF-Token': getCSRF() }, body: fd });
|
||||
const res = await fetch(window.prefix('/editor/admin/users/' + encodeURIComponent(id) + '/active'), { method: 'POST', headers: { 'X-CSRF-Token': getCSRF() }, body: fd });
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (res.ok && data.success) { showNotification('User status updated', 'success'); window.location.reload(); }
|
||||
else { showNotification('Update status failed: ' + (data.error || res.statusText), 'error'); }
|
||||
@@ -226,7 +226,7 @@
|
||||
// MFA actions
|
||||
const mfaRequest = async (row, path, okMsg) => {
|
||||
const id = row && row.getAttribute('data-user-id');
|
||||
const res = await fetch('/editor/admin/users/' + encodeURIComponent(id) + path, { method: 'POST', headers: { 'X-CSRF-Token': getCSRF() } });
|
||||
const res = await fetch(window.prefix('/editor/admin/users/' + encodeURIComponent(id) + path), { method: 'POST', headers: { 'X-CSRF-Token': getCSRF() } });
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (res.ok && data.success) { showNotification(okMsg, 'success'); window.location.reload(); }
|
||||
else { showNotification('MFA action failed: ' + (data.error || res.statusText), 'error'); }
|
||||
@@ -241,7 +241,7 @@
|
||||
formCreateGroup.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const fd = new FormData(formCreateGroup);
|
||||
const res = await fetch('/editor/admin/groups', { method: 'POST', headers: { 'X-CSRF-Token': getCSRF() }, body: fd });
|
||||
const res = await fetch(window.prefix('/editor/admin/groups'), { method: 'POST', headers: { 'X-CSRF-Token': getCSRF() }, body: fd });
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (res.ok && data.success) { showNotification('Group created', 'success'); window.location.reload(); }
|
||||
else { showNotification('Create group failed: ' + (data.error || res.statusText), 'error'); }
|
||||
@@ -257,7 +257,7 @@
|
||||
if (!id) return;
|
||||
if (name === 'admin' || name === 'public') { showNotification('Cannot delete core group: ' + name, 'error'); return; }
|
||||
if (!confirm('Delete group ' + name + ' ?')) return;
|
||||
const res = await fetch('/editor/admin/groups/' + encodeURIComponent(id), { method: 'DELETE', headers: { 'X-CSRF-Token': getCSRF() } });
|
||||
const res = await fetch(window.prefix('/editor/admin/groups/' + encodeURIComponent(id)), { method: 'DELETE', headers: { 'X-CSRF-Token': getCSRF() } });
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (res.ok && data.success) { showNotification('Group deleted', 'success'); window.location.reload(); }
|
||||
else { showNotification('Delete group failed: ' + (data.error || res.statusText), 'error'); }
|
||||
@@ -270,7 +270,7 @@
|
||||
formAddMem.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const fd = new FormData(formAddMem);
|
||||
const res = await fetch('/editor/admin/memberships/add', { method: 'POST', headers: { 'X-CSRF-Token': getCSRF() }, body: fd });
|
||||
const res = await fetch(window.prefix('/editor/admin/memberships/add'), { method: 'POST', headers: { 'X-CSRF-Token': getCSRF() }, body: fd });
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (res.ok && data.success) { showNotification('User added to group', 'success'); }
|
||||
else { showNotification('Add membership failed: ' + (data.error || res.statusText), 'error'); }
|
||||
@@ -283,7 +283,7 @@
|
||||
formRemMem.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const fd = new FormData(formRemMem);
|
||||
const res = await fetch('/editor/admin/memberships/remove', { method: 'POST', headers: { 'X-CSRF-Token': getCSRF() }, body: fd });
|
||||
const res = await fetch(window.prefix('/editor/admin/memberships/remove'), { method: 'POST', headers: { 'X-CSRF-Token': getCSRF() }, body: fd });
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (res.ok && data.success) { showNotification('User removed from group', 'success'); }
|
||||
else { showNotification('Remove membership failed: ' + (data.error || res.statusText), 'error'); }
|
||||
|
||||
Reference in New Issue
Block a user