Files
ACVE/lib/auth/teacherAllowlist.ts
2026-02-17 00:07:00 +00:00

17 lines
610 B
TypeScript

const parseTeacherEmails = (source: string | undefined): string[] =>
(source ?? "")
.split(",")
.map((email) => email.trim().toLowerCase())
.filter(Boolean);
export const readTeacherEmailsServer = (): string[] => parseTeacherEmails(process.env.TEACHER_EMAILS);
export const readTeacherEmailsBrowser = (): string[] =>
parseTeacherEmails(process.env.NEXT_PUBLIC_TEACHER_EMAILS);
export const isTeacherEmailAllowed = (email: string | null, allowed: string[]): boolean => {
if (!email) return false;
if (allowed.length === 0) return false;
return allowed.includes(email.toLowerCase());
};