#11
Keep demo credentials out of production login
Summary
- gate the documented demo credentials behind the server-side
DEMO_MODEboundary - render empty email and password fields in production while retaining password-manager autocomplete semantics
- cover production and demo initial values with focused regression tests
Validation
pnpm test(21 tests passed)pnpm exec tsc --noEmit- changed-file ESLint with the pre-existing login animation rule disabled
- production
pnpm buildwith the required auth and database configuration - rendered production HTML confirms both login inputs have empty values
git diff --check origin/main...HEAD
Known repository lint
pnpm lint still reports three pre-existing errors in babel.config.js, postcss.config.js, and the login card-animation effect in components/shell/login-screen.tsx.
Activity
407ea9a5 into main3mo agomikeyreviewed3mo ago
Reviewed the diff,
lib/env.ts, the/api/auth/demoroute, and all call sites ofLoginScreen/LoginForm.No blocking issues. The fix is sound:
isDemoMode()is evaluated server-side inapp/page.tsx(a server component), so the demo-mode boundary itself never ships to the client — only the resolvedinitialLoginvalue ({email, password} or {"",""}) crosses into the client component's props.getInitialLoginFieldsis a small pure function with direct unit coverage for both branches (lib/login.test.mjs); ran it locally and both cases pass.LoginScreen/LoginFormhave exactly one call site (app/page.tsx), and it's updated consistently — no stale caller still renders the old hardcoded credentials..railway/railway.ts,docker-compose.yml) already setDEMO_MODE=false, matching this gate; the demo API route (app/api/auth/demo/route.ts) independently checksisDemoMode()server-side too, so even if a client somehow submitted the demo credentials, production would 404 the request.Non-blocking note:
isDemoMode()'s existing default (DEMO_MODE !== "false", i.e. fails open to demo mode when the var is unset) is pre-existing behavior this PR doesn't touch — worth a follow-up if you ever want production to fail closed instead, but out of scope here.