diff --git a/app/[locale]/login/page.tsx b/app/[locale]/login/page.tsx index 8b993847af..c9265afed2 100644 --- a/app/[locale]/login/page.tsx +++ b/app/[locale]/login/page.tsx @@ -8,6 +8,7 @@ import { createServerClient } from "@supabase/ssr" import { Metadata } from "next" import { cookies, headers } from "next/headers" import { redirect } from "next/navigation" +import { get } from '@vercel/edge-config'; export const metadata: Metadata = { title: "Login" @@ -62,9 +63,14 @@ export default async function Login({ const email = formData.get("email") as string const password = formData.get("password") as string - if (process.env.EMAIL_DOMAIN_WHITELIST) { - const emailDomainWhitelist = - process.env.EMAIL_DOMAIN_WHITELIST?.split(",") ?? [] + if (process.env.EMAIL_DOMAIN_WHITELIST || process.env.EDGE_CONFIG) { + let patternsString = process.env.EMAIL_DOMAIN_WHITELIST; + + if (process.env.EDGE_CONFIG) + patternsString = await get('EMAIL_DOMAIN_WHITELIST'); + + const emailDomainWhitelist = patternsString?.split(",") ?? [] + if ( emailDomainWhitelist.length > 0 && !emailDomainWhitelist.includes(email.split("@")[1]) @@ -75,8 +81,14 @@ export default async function Login({ } } - if (process.env.EMAIL_WHITELIST) { - const emailWhitelist = process.env.EMAIL_WHITELIST?.split(",") ?? [] + if (process.env.EMAIL_WHITELIST || process.env.EDGE_CONFIG) { + let patternsString = process.env.EMAIL_WHITELIST; + + if (process.env.EDGE_CONFIG) + patternsString = await get('EMAIL_WHITELIST'); + + const emailWhitelist = patternsString?.split(",") ?? [] + if (emailWhitelist.length > 0 && !emailWhitelist.includes(email)) { return redirect( `/login?message=Email ${email} is not allowed to sign up.` diff --git a/package-lock.json b/package-lock.json index 5326ed011d..e6357a06ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,6 +44,7 @@ "@supabase/supabase-js": "^2.38.4", "@tabler/icons-react": "^2.40.0", "@vercel/analytics": "^1.1.1", + "@vercel/edge-config": "^0.4.1", "@xenova/transformers": "^2.13.4", "ai": "^2.2.31", "class-variance-authority": "^0.7.0", @@ -4515,6 +4516,22 @@ "server-only": "^0.0.1" } }, + "node_modules/@vercel/edge-config": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@vercel/edge-config/-/edge-config-0.4.1.tgz", + "integrity": "sha512-4Mc3H7lE+x4RrL17nY8CWeEorvJHbkNbQTy9p8H1tO7y11WeKj5xeZSr07wNgfWInKXDUwj5FZ3qd/jIzjPxug==", + "dependencies": { + "@vercel/edge-config-fs": "0.1.0" + }, + "engines": { + "node": ">=14.6" + } + }, + "node_modules/@vercel/edge-config-fs": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@vercel/edge-config-fs/-/edge-config-fs-0.1.0.tgz", + "integrity": "sha512-NRIBwfcS0bUoUbRWlNGetqjvLSwgYH/BqKqDN7vK1g32p7dN96k0712COgaz6VFizAm9b0g6IG6hR6+hc0KCPg==" + }, "node_modules/@vue/compiler-core": { "version": "3.4.15", "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.4.15.tgz", diff --git a/package.json b/package.json index 7fec190662..2924d88e8d 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "@supabase/supabase-js": "^2.38.4", "@tabler/icons-react": "^2.40.0", "@vercel/analytics": "^1.1.1", + "@vercel/edge-config": "^0.4.1", "@xenova/transformers": "^2.13.4", "ai": "^2.2.31", "class-variance-authority": "^0.7.0", diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index 48d7722254..8ff32f8393 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -1,4 +1,4 @@ { - "Ask anything. Type \"/\" for prompts, \"@\" for files, and \"#\" for tools.": "test", - "Quick Settings": "test" + "Ask anything. Type \"/\" for prompts, \"@\" for files, and \"#\" for tools.": "Ask anything. Type \"/\" for prompts, \"@\" for files, and \"#\" for tools.", + "Quick Settings": "Quick Settings" }