Prevent moderators from blacklisting themselves

This commit is contained in:
thePR0M3TH3AN committed 2025-09-28 21:23:33 -04:00
1 parent d39ed45c5a
commit 169f0c952c
3 files changed
+15

No files matched your search

+5
View File
@@ -283,6 +283,11 @@ class AccessControl {
return { ok: false, error: "invalid npub" };
}
const normalizedActor = normalizeNpub(actorNpub);
if (normalizedActor && normalized === normalizedActor) {
return { ok: false, error: "self" };
}
if (this.isSuperAdmin(normalized) || this.isAdminEditor(normalized)) {
return { ok: false, error: "immutable" };
}
+5
View File
@@ -448,6 +448,7 @@ async function persistNostrState(actorNpub, updates = {}) {
}
const sanitizedUpdates = {};
const actorNormalized = normalizeNpub(actorNpub);
if (Array.isArray(updates.editors)) {
sanitizedUpdates.editors = sanitizeNpubList(updates.editors).filter((npub) => {
@@ -470,6 +471,10 @@ async function persistNostrState(actorNpub, updates = {}) {
...((sanitizedUpdates.editors || []).map(normalizeNpub) || []),
]);
if (actorNormalized) {
editorGuard.add(actorNormalized);
}
sanitizedUpdates.blacklist = sanitizeNpubList(updates.blacklist).filter(
(npub) => {
const normalized = normalizeNpub(npub);
+5
View File
@@ -4304,6 +4304,8 @@ class bitvidApp {
return "Please provide a valid npub address.";
case "immutable":
return "That account cannot be modified.";
case "self":
return "You cannot blacklist yourself.";
case "forbidden":
return "You do not have permission to perform that action.";
case "nostr-unavailable":
@@ -6913,6 +6915,9 @@ class bitvidApp {
} else {
const code = result?.error || "unknown";
switch (code) {
case "self":
this.showError("You cannot blacklist yourself.");
break;
case "immutable":
this.showError(
"Moderators cannot blacklist the super admin or fellow moderators."