#11

Keep demo credentials out of production login

MergedstylesshOwnermerged intofrom

Summary

  • gate the documented demo credentials behind the server-side DEMO_MODE boundary
  • 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 build with 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

4
stylessh merged commit 07ea9a5 into main3mo ago
mikeyreviewed3mo ago
mikey3mo ago

Reviewed the diff, lib/env.ts, the /api/auth/demo route, and all call sites of LoginScreen/LoginForm.

No blocking issues. The fix is sound:

  • isDemoMode() is evaluated server-side in app/page.tsx (a server component), so the demo-mode boundary itself never ships to the client — only the resolved initialLogin value ({email, password} or {"",""}) crosses into the client component's props.
  • getInitialLoginFields is a small pure function with direct unit coverage for both branches (lib/login.test.mjs); ran it locally and both cases pass.
  • LoginScreen/LoginForm have exactly one call site (app/page.tsx), and it's updated consistently — no stale caller still renders the old hardcoded credentials.
  • Production configs (.railway/railway.ts, docker-compose.yml) already set DEMO_MODE=false, matching this gate; the demo API route (app/api/auth/demo/route.ts) independently checks isDemoMode() server-side too, so even if a client somehow submitted the demo credentials, production would 404 the request.
  • CI ("Validate application") is green.

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.

Branch stylessh/fix-production-login-prefill has been merged.

Checking branch