Fix sysadmin delete

This commit is contained in:
2026-01-22 22:19:39 +01:00
parent 14339bc018
commit 54bb2e6c49
3 changed files with 27 additions and 6 deletions

View File

@@ -187,14 +187,16 @@ function renderSystemAdministrators(admins) {
const button = document.createElement("button");
button.classList.add("button", "secondary");
button.type = "button";
button.textContent = "Remove";
button.addEventListener("click", () => removeSystemAdministrator(admin));
button.setAttribute("data-sysadmin-remove", "true");
button.setAttribute("data-sysadmin-username", admin);
if (isInitialSysadmin) {
button.disabled = true;
button.title = "The initial system administrator cannot be removed.";
button.textContent = "System default";
button.title = "The system default administrator cannot be removed.";
} else {
button.textContent = "Remove";
button.addEventListener("click", () => removeSystemAdministrator(admin));
}
listItem.appendChild(text);
@@ -226,6 +228,10 @@ function addSystemAdministrator() {
showToast("Enter a Twitch username", "warning");
return;
}
if (initialSysadmin && username.toLowerCase() === initialSysadmin) {
showToast("That user is already the system default administrator.", "warning");
return;
}
fetch("/api/system-administrators", {
method: "POST",
headers: { "Content-Type": "application/json" },