This commit is contained in:
2026-02-13 21:50:00 +01:00
parent dbfd99f410
commit 6566816dcf
9 changed files with 205 additions and 27 deletions

View File

@@ -432,6 +432,7 @@ const adminPanelHTML = `<!DOCTYPE html>
'<td>' + (c.enabled ? '<span class="badge badge-success">Enabled</span>' : '<span class="badge badge-danger">Disabled</span>') + '</td>' +
'<td>' +
'<button class="btn btn-sm btn-warning" onclick="editClient(\'' + c.client_id + '\')">Edit</button>' +
'<button class="btn btn-sm" style="background: #9b59b6; color: white;" onclick="resetClientPassword(\'' + c.client_id + '\')">Reset Key</button>' +
'<button class="btn btn-sm btn-danger" onclick="deleteClient(\'' + c.client_id + '\')">Delete</button>' +
'</td>' +
'</tr>';
@@ -756,6 +757,24 @@ const adminPanelHTML = `<!DOCTYPE html>
}
}
// Reset client password/API key
async function resetClientPassword(clientId) {
if (!confirm('Reset API key for client "' + clientId + '"? The new key will be shown once.')) return;
try {
const res = await fetch('/admin/client/reset-password?client_id=' + clientId, { method: 'POST' });
const data = await res.json();
if (data.success) {
// Show the new API key in a prompt so it can be copied
prompt('New API key for ' + clientId + ' (copy this now - it won\\'t be shown again):', data.api_key);
} else {
alert(data.message || 'Failed to reset client password');
}
} catch (e) {
alert('Failed to reset client password');
}
}
// Initialize
checkAuth();
</script>