Skip to content

refactor(better-auth): login/signup#4592

Draft
jog1t wants to merge 18 commits into04-04-chore_migrate_to_better-authfrom
04-08-refactor_better-auth_login_signup
Draft

refactor(better-auth): login/signup#4592
jog1t wants to merge 18 commits into04-04-chore_migrate_to_better-authfrom
04-08-refactor_better-auth_login_signup

Conversation

@jog1t
Copy link
Copy Markdown
Contributor

@jog1t jog1t commented Apr 8, 2026

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

jog1t added 18 commits April 8, 2026 00:16
@railway-app
Copy link
Copy Markdown

railway-app bot commented Apr 8, 2026

🚅 Deployed to the rivet-pr-4592 environment in rivet-frontend

Service Status Web Updated (UTC)
frontend-inspector ❌ Build Failed (View Logs) Web Apr 8, 2026 at 6:47 pm
frontend-cloud ❌ Build Failed (View Logs) Web Apr 8, 2026 at 6:46 pm
mcp-hub ✅ Success (View Logs) Web Apr 8, 2026 at 6:46 pm
kitchen-sink ❌ Build Failed (View Logs) Web Apr 8, 2026 at 6:46 pm
website ❌ Build Failed (View Logs) Web Apr 8, 2026 at 6:46 pm
ladle ❌ Build Failed (View Logs) Web Apr 8, 2026 at 6:46 pm

Copy link
Copy Markdown
Contributor Author

jog1t commented Apr 8, 2026

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.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown

claude bot commented Apr 8, 2026

PR Review: refactor(better-auth): login/signup

This 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.


Bugs

from 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 Concerns

attemptAsync 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

  • Route renames and existing deep links. Routes under _context/_cloud/ and _context/_engine/ are flattened to _context/. Since TanStack uses _ prefixes for pathless layouts, these segments likely were not visible in URLs -- but worth a quick confirm.

  • orgs.organization.tsx setActive guard -- the optimization to skip setActive when the org is already active is a nice improvement.

  • The PR description is empty. Even a one-line summary of the motivation (replace compile-time APP_TYPE with runtime feature flags) would help reviewers and the git log.

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.

1 participant