feat(auth): migrate NextAuth → better-auth (fleet standard)#6
Merged
Conversation
Bland flat dark-only UI with generic indigo accent and hardcoded dark-only status colors (unreadable if light mode ever shipped). Wires up next-themes (already a dependency, unused), swaps accent to teal, adds real elevation layering, promotes status colors to semantic theme tokens, and upgrades the shared DataTable primitive (pagination, sticky header) used by every table in the app. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vo2PcDtDzHok5EFJ4STR8F
Adopts better-auth as the single auth system per the app-starter-skills standard. Verified end-to-end against the dev DB: owner signup, single- owner lockdown, login, and wrong-password rejection all behave correctly. - better-auth server (lib/auth.ts): email+password, twoFactor (TOTP + backup codes, built-in verification lockout), bearer (mobile tokens), rateLimit, and a databaseHooks guard enforcing SINGLE OWNER (first sign-up allowed, all later ones rejected even via direct API). - Route handler api/auth/[...all]; client lib/auth-client.ts with twoFactorClient; middleware uses getSessionCookie (edge-safe). - Rewrote auth-actions/auth-service/_helpers/layout/account to the better-auth server API; removed the NextAuth files and the custom bcrypt/passwordHash path. - Prisma: better-auth tables (user/session/account/verification/ twoFactor) generated via the CLI; dropped User.passwordHash. - 2FA UI: account TotpCard (password step-up to enable AND disable) and a /login/2fa step; login routes there on twoFactorRedirect. - Seed no longer creates a default-credential user; the owner is created through /setup. Removed next-auth, @auth/prisma-adapter, bcryptjs.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
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.
Migrates sidekit off NextAuth to better-auth — the fleet auth standard defined in
app-starter-skills. Sidekit is the reference implementation the other repos will copy.What changed
lib/auth.ts): email+password,twoFactor(TOTP + single-use backup codes + built-in verify lockout),bearer(mobile/native tokens),rateLimit, and adatabaseHookssingle-owner guard (first sign-up allowed, later ones rejected even via direct API).api/auth/[...all], clientlib/auth-client.ts(twoFactorClient), middleware viagetSessionCookie(edge-safe).auth-actions/auth-service/_helpers/layout/accountto the better-auth server API. Removed the NextAuth files + custombcrypt/passwordHashpath.User.passwordHash./login/2fa./setup. Removednext-auth,@auth/prisma-adapter,bcryptjs.Verification
tscclean, and exercised against the dev DB:🤖 Generated with Claude Code