Skip to content

Commit

Permalink
Feature: Email whitelist (mckaywrigley#1221)
Browse files Browse the repository at this point in the history
Co-authored-by: Franco Fantini <francofantini@Francos-MBP.fibertel.com.ar>
  • Loading branch information
francofantini and Franco Fantini authored Jan 21, 2024
1 parent b4ec5a0 commit 54d3db0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ NEXT_PUBLIC_AZURE_OPENAI_ENDPOINT=
NEXT_PUBLIC_AZURE_GPT_35_TURBO_ID=
NEXT_PUBLIC_AZURE_GPT_45_VISION_ID=
NEXT_PUBLIC_AZURE_GPT_45_TURBO_ID=

# General Configuration (Optional)
EMAIL_DOMAIN_WHITELIST=
EMAIL_WHITELIST=
15 changes: 15 additions & 0 deletions app/[locale]/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ export default async function Login({

const email = formData.get("email") as string
const password = formData.get("password") as string

const emailDomainWhitelist = process.env.EMAIL_DOMAIN_WHITELIST?.split(",") ?? []
if (emailDomainWhitelist.length > 0 && !emailDomainWhitelist.includes(email.split("@")[1])) {
return redirect(
`/login?message=Email ${email} is not allowed to sign up.`
)
}

const emailWhitelist = process.env.EMAIL_WHITELIST?.split(",") ?? []
if (emailWhitelist.length > 0 && !emailWhitelist.includes(email)) {
return redirect(
`/login?message=Email ${email} is not allowed to sign up.`
)
}

const cookieStore = cookies()
const supabase = createClient(cookieStore)

Expand Down

0 comments on commit 54d3db0

Please sign in to comment.