advance
This commit is contained in:
16
lib/auth/teacherAllowlist.ts
Normal file
16
lib/auth/teacherAllowlist.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
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());
|
||||
};
|
||||
Reference in New Issue
Block a user