Remove sign-in screen; serve every request as a default user - #3
Merged
Conversation
added 2 commits
August 17, 2026 08:00
Auth pages and the route guard are gone: "Get Started" goes straight to /dashboard, and /login, /signup and /auth redirect there so old links don't 404. requireAuth now resolves a default user when no usable token is present, picked by DEMO_USER_EMAIL, else the first ADMIN, else the first row in the User table. A valid token still wins; an expired or malformed one falls back instead of 401-ing, since Render regenerates NEXTAUTH_SECRET on deploy and would otherwise brick stale browser sessions. Also: - GET /api/auth/session tells the SPA which user it is acting as, with authLimiter narrowed to the credential routes so this per-load lookup is not rate-limited to 10/15min. - An unresolvable session returns 503 with the real DB error and the env vars to check, instead of a generic 500. - Drop the hardcoded Supabase project fallback in lib/supabase.ts; a stale project ref turned every query into an opaque DNS failure. - OAuth Connect buttons no longer require a localStorage token that can no longer exist. - Document DEMO_USER_EMAIL in .env.example and render.yaml.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the "API failed" errors on the live site.
What changed
No more login.
src/pages/Auth.tsxandsrc/components/ProtectedRoute.tsxare deleted. "Get Started" goes straight to/dashboard;/login,/signupand/authredirect there so old links do not 404. The sidebar "Sign out" button and the redirect-to-login effect inClientLayoutare gone.requireAuthresolves a default user. Every data route sat behindrequireAuth, so with no login there was no token and/api/proposals,/api/rules,/api/analytics/summaryand/api/auditall returned 401. The middleware now falls back to a default user picked byDEMO_USER_EMAIL, else the firstADMIN, else the first row inUser. A valid token still wins; an expired or malformed one falls back instead of 401-ing.Also:
GET /api/auth/sessiontells the SPA which user it is acting as.authLimitermoved from the whole/api/authmount onto just the credential routes, so this per-page-load lookup is not rate-limited to 10/15min.src/lib/supabase.tsused as a fallback forSUPABASE_URL. A stale ref turned every query into an opaque DNS failure instead of naming the missing config.DEMO_USER_EMAILdocumented in.env.exampleandrender.yaml, pointed atadmin@reviewer.ai(the actual seeded admin).Verification
tsc --noEmitclean, eslint 0 errors,vite buildsucceeds, 51/51 tests pass. The auth/notifications tests that asserted the old 401 behavior were rewritten, with new cases for an empty User table and an unreachable DB.Smoke-tested against the local server with the restored database:
Before merging
autoDeployis on, so merging deploys. SetSUPABASE_URL,SUPABASE_ANON_KEYandDATABASE_URLin the Render dashboard to the restored project first, or the live site will 503 on session lookup.