Skip to content

feat(admin): sign in locally as a test user; retire ADMIN_DEV_BYPASS - #1666

Merged
JoeKarow merged 8 commits into
mainfrom
feat/dev-sign-in-panel
Oct 7, 2026
Merged

JoeKarow merged 8 commits into
mainfrom
feat/dev-sign-in-panel

Conversation

@JoeKarow

@JoeKarow JoeKarow commented Oct 7, 2026

Copy link
Copy Markdown
Member

Linked Issue

Closes #1665

Description

  • Test-user panel on the sign-in pages. TestUserPanel (src/app/admin/testUserPanel.tsx) renders the better-auth-devtools panel on /admin/sign-in, /invites/sign-in and the protected /admin layout, so a signed-out browser can pick a seeded admin, CoC reviewer or Volunteer.
  • Local-only guard. devtoolsEnabled() in src/lib/access/devtools.ts (deployContext() === 'local') is both the plugin's enabled and the panel's render check, on top of the library's own NODE_ENV refusal. That keeps the defence in depth the bypass had.
  • Empty state. Locally, when Slack isn't configured, both sign-in pages say to run pnpm db:seed and pick a test user. Deploys keep the misconfiguration warning.
  • Bypass removed.
    • devBypassSession() and the cookie-vs-bypass precedence in getSession() are deleted.
    • The three ADMIN_DEV_BYPASS* vars are gone from netlify/env.d.ts, and .env.example gets a short pointer instead.
  • Seed.
    • The admin is now dev-seed-admin / U_DEV_ADMIN.
    • reset() also clears seeded users by email, so a database seeded under the old id reseeds cleanly.
  • Tests.
    • The bypass cases are deleted.
    • requireVolunteer moved to volunteerAccess.db.test.ts on real sessions via signInAs(). It now covers the no-Slack-id redirect.
  • Docs. docs/agents/membership.md, ADR 0010, ADR 0018 and docs/testing.md now describe the panel, not the bypass.

Methodology

The panel's login endpoint needs no existing session, and pnpm db:seed already registers a test user per role. The bypass therefore bought nothing a contributor couldn't get from the panel, because /admin needs the local database either way. It did cost a second, in-memory identity with no user row, plus precedence logic so the two could coexist.

Verified in the browser on a fresh netlify dev:

  • Signed out, picking the seeded admin on /admin/sign-in lands on /admin.
  • Signed out, picking the seeded Volunteer on /invites/sign-in lands on /invites with their allowance.

The "Slack not configured" hint wasn't exercised in the browser, because the local .env has Slack credentials. pnpm codegen && pnpm typecheck && pnpm lint && pnpm test && pnpm knip pass: 94 files, 1075 tests.

Code of Conduct

By submitting this pull request, you agree to follow our Code of Conduct

Local sign-in without Slack is the devtools panel, gated on the local
deploy context. Both sign-in pages point at pnpm db:seed when Slack is
not configured. Refs #1665.
getSession() is the cached Better Auth lookup. The seeded admin is a
real, devtools-registered user (dev-seed-admin). requireVolunteer tests
move to a db test with real sessions. Refs #1665.
A database seeded as dev-bypass kept that row, and its email blocked the
insert of dev-seed-admin. Refs #1665
@JoeKarow
JoeKarow requested review from a team as code owners October 7, 2026 01:47
@netlify

netlify Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for virtual-coffee-io ready!

Name Link
🔨 Latest commit f24f918
🔍 Latest deploy log https://app.netlify.com/projects/virtual-coffee-io/deploys/6ac5b1a607de6b0b64407d4e
😎 Deploy Preview https://deploy-preview-1666--virtual-coffee-io.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 74 (🔴 down 8 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 84.02% 2031 / 2417
🔵 Statements 83.43% 2226 / 2668
🔵 Functions 79.6% 566 / 711
🔵 Branches 81.67% 1524 / 1866
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/lib/access/adminAccess.ts 100% 80% 100% 100%
src/lib/access/devtools.ts 30% 0% 33.33% 30% 30, 48-67
src/lib/access/volunteerAccess.ts 100% 100% 100% 100%
src/lib/waitlist/lifecycle.ts 97.63% 96.8% 100% 98.09% 169-172, 326, 468
Generated in workflow #1200 for commit f24f918 by the Vitest Coverage Report Action

@greptile-apps

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Replaces environment-variable dev bypass with database-backed test user sign-in.

The PR appears safe to merge; no blocking findings remain.

What we checked:

  • Hidden panel offered for sign-in: devtoolsEnabled() returns false in production builds. Both the panel and the test-user hint use that check.

Summary

Replaces ADMIN_DEV_BYPASS with real test-user sessions through the local sign-in panel.

  • Adds TestUserPanel to both sign-in pages and the protected admin layout.
  • Updates seeded identities, cleanup, tests, and contributor docs.
  • The changes since the previous review are empty.
  • The prior sign-in hint issue is fixed: devtoolsEnabled() now excludes production builds. No new findings or rule violations were found.

Reviews (4) · Last reviewed commit: "chore: retrigger the deploy preview" · Reviewed by Greptile

Comment thread src/lib/access/devtools.ts
devtoolsEnabled() now repeats the library's NODE_ENV check, so a local
production build doesn't point at a panel that never renders. Refs #1665
The local test-user hint and the deploy warning are one component, so the
pages no longer branch on devtoolsEnabled(). The /invites copy also named
only two of the three Slack variables slackAuthConfigured requires. Refs #1665
The previous preview build got no database URL from Netlify, so the
migrate step failed before touching anything.
@JoeKarow
JoeKarow merged commit 6c686e2 into main Oct 7, 2026
13 checks passed
@JoeKarow
JoeKarow deleted the feat/dev-sign-in-panel branch October 7, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace ADMIN_DEV_BYPASS with test-user sign-in on the sign-in pages

1 participant