da4ce99755
* Add dev target for TheoremOne * Restrict signups to theoremone.co emails * Add new indices * Forbid reads from unauthenticated users * Client-side render pages that need auth These pages are now client-side rendered: - /home - /leaderboards - /market/... - /fold/... * Hide 404 for private Manifolds * Brand instance for TheoremOne * Hide "Add Funds" and "Personalize your feed" * "M$" => "T$" * Hide Discord & About Page too * Update placeholders for teams * Update firestore.indexes.json * Switch /analytics to propz * Migrate per-env code into common/ * More migrations to PROJECT_ID * Conditionally use SSG depending on public vs private instance * Fix props to be empty object * Move more logic into access * Spin out config files for each environment * Generify most of the customizable brand stuff * Move IS_PRIVATE_MANIFOLD to access.ts * Rename access.ts to envs/constants.ts * Add "dev:dev" alias * Rever firestore rules to existing settings * Fixes according to James's review
31 lines
926 B
TypeScript
31 lines
926 B
TypeScript
import { DEV_CONFIG } from './dev'
|
|
import { EnvConfig, PROD_CONFIG } from './prod'
|
|
import { THEOREMONE_CONFIG } from './theoremone'
|
|
|
|
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
|
|
}
|
|
return email && (email.endsWith(ENV_CONFIG.whitelistEmail) || isAdmin(email))
|
|
}
|
|
|
|
// TODO: Before open sourcing, we should turn these into env vars
|
|
export function isAdmin(email: string) {
|
|
return ENV_CONFIG.adminEmails.includes(email)
|
|
}
|
|
|
|
export const DOMAIN = ENV_CONFIG.domain
|
|
export const FIREBASE_CONFIG = ENV_CONFIG.firebaseConfig
|
|
export const PROJECT_ID = ENV_CONFIG.firebaseConfig.projectId
|
|
export const IS_PRIVATE_MANIFOLD = ENV_CONFIG.visibility === 'PRIVATE'
|