mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-07 05:13:01 +00:00
Prevent moderators from blacklisting themselves
This commit is contained in:
1 parent
d39ed45c5a
commit
169f0c952c
3 files changed
+15
No files matched your search
@@ -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" };
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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."
|
||||
|
||||
Reference in new issue
Block a user