feat : able to use mutil email
This commit is contained in:
@@ -23,6 +23,21 @@ describe("admin authorization", () => {
|
||||
expect(isConfiguredAdminEmail(verified.email, undefined)).toBe(false);
|
||||
});
|
||||
|
||||
it("supports a comma-separated administrator email list", () => {
|
||||
expect(
|
||||
isConfiguredAdminEmail(
|
||||
"[email protected]",
|
||||
"[email protected], [email protected]",
|
||||
),
|
||||
).toBe(true);
|
||||
expect(
|
||||
isConfiguredAdminEmail(
|
||||
"[email protected]",
|
||||
"[email protected], [email protected]",
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("allows only credential registration for the configured administrator", () => {
|
||||
expect(
|
||||
isAllowedAdminRegistration(
|
||||
|
||||
@@ -8,9 +8,15 @@ export interface SessionUserLike {
|
||||
|
||||
export function isConfiguredAdminEmail(
|
||||
email: string | null | undefined,
|
||||
adminEmail: string | null | undefined,
|
||||
adminEmailConfig: string | null | undefined,
|
||||
): boolean {
|
||||
return Boolean(email && adminEmail && email === adminEmail);
|
||||
if (!email || !adminEmailConfig) return false;
|
||||
|
||||
return adminEmailConfig
|
||||
.split(",")
|
||||
.map((configuredEmail) => configuredEmail.trim())
|
||||
.filter(Boolean)
|
||||
.includes(email);
|
||||
}
|
||||
|
||||
export function isAllowedAdminRegistration(
|
||||
|
||||
Reference in New Issue
Block a user