From b5d2d044018029cf884e540ae14e26b2b32073dd Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Thu, 15 Jan 2026 14:31:51 -0500 Subject: [PATCH] Add access control check to login --- js/services/authService.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/js/services/authService.js b/js/services/authService.js index 69714205..dafec531 100644 --- a/js/services/authService.js +++ b/js/services/authService.js @@ -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") {