Add access control check to login

This commit is contained in:
thePR0M3TH3AN committed 2026-01-15 14:31:51 -05:00
1 parent 44d328bfa0
commit b5d2d04401
1 file changed
+29
+29
View File
@@ -500,6 +500,35 @@ export default class AuthService {
}
}
if (control && typeof control.canAccess === "function") {
let canAccess = true;
try {
canAccess = control.canAccess(candidateNpub || nextPubkey);
} catch (error) {
this.log("[AuthService] accessControl.canAccess threw", error);
canAccess = Boolean(canAccess);
}
if (!canAccess) {
let isBlocked = false;
if (typeof control.isBlacklisted === "function") {
try {
isBlocked = control.isBlacklisted(candidateNpub || nextPubkey);
} catch (error) {
this.log("[AuthService] accessControl.isBlacklisted threw", error);
isBlocked = false;
}
}
const accessError = new Error(
isBlocked
? "Your account has been blocked on this platform."
: "Access restricted to admins and moderators users only.",
);
throw accessError;
}
}
if (normalized) {
setPubkey(normalized);
if (this.nostrClient && typeof this.nostrClient === "object") {