manifold/common/access.ts

30 lines
870 B
TypeScript
Raw Normal View History

import { DEV_CONFIG } from './envs/dev'
import { EnvConfig, PROD_CONFIG } from './envs/prod'
import { THEOREMONE_CONFIG } from './envs/theoremone'
2022-03-08 01:43:23 +00:00
const ENV = process.env.NEXT_PUBLIC_FIREBASE_ENV ?? 'PROD'
const CONFIGS = {
PROD: PROD_CONFIG,
DEV: DEV_CONFIG,
THEOREMONE: THEOREMONE_CONFIG,
}
// @ts-ignore
export const ENV_CONFIG: EnvConfig = CONFIGS[ENV]
export function isWhitelisted(email?: string) {
if (!ENV_CONFIG.whitelistEmail) {
return true
2022-03-08 01:43:23 +00:00
}
return email && (email.endsWith(ENV_CONFIG.whitelistEmail) || isAdmin(email))
}
2022-03-08 01:43:23 +00:00
// TODO: Before open sourcing, we should turn these into env vars
export function isAdmin(email: string) {
return ENV_CONFIG.adminEmails.includes(email)
}
2022-03-07 23:43:26 +00:00
export const DOMAIN = ENV_CONFIG.domain
export const FIREBASE_CONFIG = ENV_CONFIG.firebaseConfig
export const PROJECT_ID = ENV_CONFIG.firebaseConfig.projectId