From 21180c2ff01c2fbc19e10b8682884fdd5476f23a Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Mon, 7 Mar 2022 17:43:23 -0800 Subject: [PATCH] Move more logic into access --- common/access.ts | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/common/access.ts b/common/access.ts index 8b630f39..68fddd0f 100644 --- a/common/access.ts +++ b/common/access.ts @@ -1,7 +1,17 @@ +const ENV = process.env.NEXT_PUBLIC_FIREBASE_ENV ?? 'PROD' + export function isWhitelisted(email?: string) { - return email && (email.endsWith('@theoremone.co') || isAdmin(email)) + switch (ENV) { + case 'THEOREMONE': + return email && (email.endsWith('@theoremone.co') || isAdmin(email)) + case 'PROD': + case 'DEV': + default: + return true + } } +// TODO: Before open sourcing, we should turn these into env vars export function isAdmin(email: string) { const ADMINS = [ 'akrolsmir@gmail.com', // Austin @@ -9,17 +19,12 @@ export function isAdmin(email: string) { 'taowell@gmail.com', // Stephen 'manticmarkets@gmail.com', // Manifold ] + if (ENV === 'THEOREMONE') { + ADMINS.push('david.glidden@theoremone.co') + } return ADMINS.includes(email) } -const ENV = process.env.NEXT_PUBLIC_FIREBASE_ENV ?? 'PROD' - -export const DOMAINS = { - PROD: 'manifold.markets', - DEV: 'manifold.markets', - THEOREMONE: 'theoremone.manifold.markets', -} - export const FIREBASE_CONFIGS = { PROD: { apiKey: 'AIzaSyDp3J57vLeAZCzxLD-vcPaGIkAmBoGOSYw', @@ -50,6 +55,11 @@ export const FIREBASE_CONFIGS = { }, } +const DOMAINS = { + PROD: 'manifold.markets', + DEV: 'manifold.markets', + THEOREMONE: 'theoremone.manifold.markets', +} // @ts-ignore export const DOMAIN = DOMAINS[ENV] // @ts-ignore