// ── Demo mode: the flag and the four shared accounts ─────────────────────── // // `DEMO_MODE=true` on a deployment turns it into the public demo // (docs/website/DEMO_MODE.md). Read per call rather than once at require time, // so a test can flip it without re-requiring every file that asks — and so // there is exactly one spelling of "is this the demo" in the codebase. // // Only the literal string `true` turns it on. A stray `DEMO_MODE=1` or `yes` on // a real shard must not lock its admin panel, and the opposite mistake — a demo // that forgot the flag — is caught by `seed:demo`, which refuses to run without it. function isDemo() { return process.env.DEMO_MODE === 'true' } // The static logins (DEMO_MODE.md §4). Fixed here, in core, rather than read // from the seed fixture: the lock has to recognise them on every request, and a // fixture that dropped one would quietly unlock the account everybody shares. // The seed creates exactly these; their passwords come from the fixture. const DEMO_ACCOUNTS = Object.freeze(['demo-admin', 'demo-moderator', 'demo-player', 'play-review']) function isDemoUsername(username) { return typeof username === 'string' && DEMO_ACCOUNTS.includes(username.toLowerCase()) } module.exports = { isDemo, DEMO_ACCOUNTS, isDemoUsername }