mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Add access control check to login
This commit is contained in:
1 parent
44d328bfa0
commit
b5d2d04401
1 file changed
+29
@@ -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") {
|
||||
|
||||
Reference in new issue
Block a user