refactor(better-auth): login/signup#4592
refactor(better-auth): login/signup#4592jog1t wants to merge 18 commits into04-04-chore_migrate_to_better-authfrom
Conversation
…rted to feature flags
…rding footer support button
…s.tsx to features flags
…to _context level
… to _context level
|
🚅 Deployed to the rivet-pr-4592 environment in rivet-frontend
|
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR Review: refactor(better-auth): login/signupThis is a solid refactor that replaces the compile-time APP_TYPE global with a runtime feature-flag system and simplifies the login/signup forms. The overall direction is good. A few issues to address before merging. Bugsfrom param dropped in login.tsx and sign-up.tsx In both files, from is extracted from the search params but never forwarded to redirectToOrganization. The original code passed from ? { from } : {}. Users who follow a deep link to the login page will always be redirected to their org root instead of the originally-intended URL after login. No-org fallback is silent redirectToOrganization now returns false when the user has no orgs (instead of redirecting to /onboarding/choose-organization). The callers do not handle this case -- if the return value is false, nothing happens and the user stays on the login page with no feedback. This leaves new users stuck on the login page after a successful authentication. The removed /onboarding/choose-organization redirect covered this case previously. Consider either restoring that redirect or adding an explicit fallback navigation here. crypto.randomUUID() as org slug create-organization-frame.tsx now sends crypto.randomUUID() as the slug. The comment says the server generates the real slug, but this assumption should be verified. If the better-auth organization.create API stores whatever slug the client sends, org slugs will be unreadable UUIDs in URLs and the database. Design ConcernsattemptAsync for redirect handling is non-idiomatic TanStack Router redirects are thrown errors, and the router catches them when they propagate naturally up the call stack. Using attemptAsync to catch the throw and then re-navigating manually adds an extra layer of indirection with no clear benefit. The original pattern of re-throwing redirect errors was awkward, but this approach adds a new dependency (es-toolkit) to solve the same problem less clearly. Consider using a try/catch that only catches non-redirect errors, or restructuring redirectToOrganization to return a navigation target instead of throwing. Feature flags default to all-on The inverted default (raw === undefined ? null : new Set(...)) means a deployment that forgets to set VITE_FEATURE_FLAGS silently enables every feature, including auth, billing, and multitenancy. Worth documenting in an env var reference or .env.example so operators know to explicitly set the var for engine/inspector builds. Also: if someone sets localStorage.FEATURE_FLAGS to an empty string in dev to clear an override, they get all flags disabled (empty Set) rather than falling back to the env var default. The empty-string case and the unset case are not treated symmetrically. Minor
|

Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: