mirror of
https://github.com/andrey271192/PCAtelegram_web.git
synced 2026-09-20 11:55:32 +00:00
fix: allow disabling main key
This commit is contained in:
@@ -2285,9 +2285,6 @@ class AdminHandler(BaseHTTPRequestHandler):
|
|||||||
), "restart": {"mode": "async", "requested": restart_requested}})
|
), "restart": {"mode": "async", "requested": restart_requested}})
|
||||||
elif path.startswith("/api/users/") and path.endswith("/enabled"):
|
elif path.startswith("/api/users/") and path.endswith("/enabled"):
|
||||||
name = urllib.parse.unquote(path[len("/api/users/"):-len("/enabled")])
|
name = urllib.parse.unquote(path[len("/api/users/"):-len("/enabled")])
|
||||||
if name == "main":
|
|
||||||
self.send_error_json(400, "main user cannot be disabled")
|
|
||||||
return
|
|
||||||
enabled = bool(body.get("enabled"))
|
enabled = bool(body.get("enabled"))
|
||||||
try:
|
try:
|
||||||
with FileLock(USER_LOCK_FILE):
|
with FileLock(USER_LOCK_FILE):
|
||||||
|
|||||||
@@ -1302,8 +1302,8 @@ function renderUsers() {
|
|||||||
<strong>${escapeHtml(user.name)}</strong>${user.main ? ` <small>${escapeHtml(t("main"))}</small>` : ""}
|
<strong>${escapeHtml(user.name)}</strong>${user.main ? ` <small>${escapeHtml(t("main"))}</small>` : ""}
|
||||||
</button>
|
</button>
|
||||||
<div class="status-control">
|
<div class="status-control">
|
||||||
<label class="switch" title="${escapeAttr(user.main ? t("main") : (user.enabled ? t("disableKey") : t("enableKey")))}">
|
<label class="switch" title="${escapeAttr(user.enabled ? t("disableKey") : t("enableKey"))}">
|
||||||
<input type="checkbox" data-toggle-user="${escapeAttr(user.name)}" ${user.enabled ? "checked" : ""} ${user.main || pending ? "disabled" : ""}>
|
<input type="checkbox" data-toggle-user="${escapeAttr(user.name)}" ${user.enabled ? "checked" : ""} ${pending ? "disabled" : ""}>
|
||||||
<span></span>
|
<span></span>
|
||||||
</label>
|
</label>
|
||||||
<strong class="${user.enabled ? "state-on" : "state-off"}">${escapeHtml(pending ? t("applying") : (user.enabled ? t("enabled") : t("disabled")))}</strong>
|
<strong class="${user.enabled ? "state-on" : "state-off"}">${escapeHtml(pending ? t("applying") : (user.enabled ? t("enabled") : t("disabled")))}</strong>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
document.documentElement.dataset.theme = theme;
|
document.documentElement.dataset.theme = theme;
|
||||||
}());
|
}());
|
||||||
</script>
|
</script>
|
||||||
<link rel="stylesheet" href="/styles.css?v=2.5.0-admin26">
|
<link rel="stylesheet" href="/styles.css?v=2.5.0-admin27">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="app-shell">
|
<div class="app-shell">
|
||||||
@@ -482,6 +482,6 @@
|
|||||||
<button id="qrCopyBtn" type="button" class="soft" data-i18n="copyLink">Copy link</button>
|
<button id="qrCopyBtn" type="button" class="soft" data-i18n="copyLink">Copy link</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="/app.js?v=2.5.0-admin26" type="module"></script>
|
<script src="/app.js?v=2.5.0-admin27" type="module"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user