brackt/app/components
Chris Parsons cca546b0f5 Migrate authentication from Clerk to BetterAuth (#322)
Replaces @clerk/react-router with self-hosted better-auth to eliminate
the external Clerk dependency and keep all user/session data in our own
PostgreSQL database.

**What changed**
- New: auth.server.ts (BetterAuth config w/ Drizzle adapter, bcrypt, Resend), auth-client.ts, api.auth.$.ts handler
- New: /login and /register pages with email+password and Google/Discord OAuth; open-redirect guard on redirectTo param
- New: UserMenu component replacing Clerk's UserButton
- Schema: sessions, accounts, verifications tables; emailVerified column; clerkId made nullable
- Migrations 0081 (BetterAuth tables) and 0082 (accounts extra columns for v1.6.9)
- All ~30 route files: getAuth → auth.api.getSession, isUserAdminByClerkId → isUserAdmin
- root.tsx: isAdmin read directly from session.user.isAdmin (no extra DB query)
- useDraftAuthRecovery: removed Clerk JWT refresh logic; replaced with cookie-session check
- models/user.ts: removed findUserByClerkId, findOrCreateUser, updateUserByClerkId (webhook pattern)
- Deleted: app/routes/api/webhooks/clerk.ts; uninstalled @clerk/react-router, @clerk/themes, svix
- scripts/migrate.mjs: extended with idempotent Clerk → BetterAuth data migration (FK conversion, email_verified, OAuth accounts)
- scripts/migrate-clerk-passwords.mjs: one-time script to import bcrypt hashes from Clerk CSV export
- BETTERAUTH_MIGRATION.md: dev and production runbooks
- All test mocks updated: vi.mock('~/lib/auth.server') instead of @clerk/react-router/server
- Test fixtures: added emailVerified field

**Follow-up (post-stable)**
- Rename actor_clerk_id column → actor_user_id in commissioner_audit_log
- Drop clerk_id column from users once migration confirmed

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24 21:44:43 -07:00
..
__tests__ New design (#309) 2026-04-23 13:14:55 -07:00
draft Add Storybook stories for new components from staged changes (#321) 2026-04-23 22:09:25 -07:00
league Add Storybook stories for new components from staged changes (#321) 2026-04-23 22:09:25 -07:00
marketing Add Storybook stories for new components from staged changes (#321) 2026-04-23 22:09:25 -07:00
scoring Add Storybook stories for new components from staged changes (#321) 2026-04-23 22:09:25 -07:00
sport-season New design (#309) 2026-04-23 13:14:55 -07:00
sports Display upcoming matches (#141) 2026-03-12 10:12:38 -07:00
standings Add Storybook stories for new components from staged changes (#321) 2026-04-23 22:09:25 -07:00
ui Add Storybook stories for new components from staged changes (#321) 2026-04-23 22:09:25 -07:00
AutodraftSettings.tsx New design (#309) 2026-04-23 13:14:55 -07:00
BatchResultEntry.tsx feat: batch qualifying results entry (#290) 2026-04-12 14:52:22 -07:00
DraftGrid.tsx New design (#309) 2026-04-23 13:14:55 -07:00
DraftSidebar.tsx New design (#309) 2026-04-23 13:14:55 -07:00
navbar.tsx Migrate authentication from Clerk to BetterAuth (#322) 2026-04-24 21:44:43 -07:00
NavigationProgress.tsx Add NProgress navigation progress bar (#139) 2026-03-11 22:02:48 -07:00
NotificationSettings.tsx New design (#309) 2026-04-23 13:14:55 -07:00
ParticipantSelector.tsx feat: Add ParticipantSelector component for improved participant selection in brackets 2025-11-08 21:36:29 -08:00
StandingsTable.tsx Show tied ranks with T prefix across standings and Discord (#239) 2026-03-27 20:45:15 -07:00
TeamAvatar.stories.tsx Add Storybook stories for new components from staged changes (#321) 2026-04-23 22:09:25 -07:00
TeamAvatar.tsx Add Storybook stories for new components from staged changes (#321) 2026-04-23 22:09:25 -07:00
UserMenu.tsx Migrate authentication from Clerk to BetterAuth (#322) 2026-04-24 21:44:43 -07:00