[1] Better Auth - Schema + Compatibility - #4284
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe PR adds Better Auth-compatible Prisma fields and models. It updates the authentication adapter and password reset flow to persist ChangesAuthentication verification support
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This change is merge-ready after normal checks and review; no actionable merge-blocking risk remains. Sequence Diagram(s)sequenceDiagram
participant AuthFlow
participant PrismaAdapter
participant UserRecord
AuthFlow->>PrismaAdapter: create or update verification data
PrismaAdapter->>UserRecord: persist emailVerified and emailVerifiedBa
UserRecord-->>PrismaAdapter: return updated user
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/lib/auth/options.ts`:
- Around line 67-70: Update the emailVerified update object so that whenever
emailVerified !== undefined, it also assigns emailVerifiedBa to
Boolean(emailVerified), including when verification is cleared with null; remove
the conditional true-only assignment while preserving the surrounding update
flow.
In `@apps/web/prisma/schema/schema.prisma`:
- Around line 15-16: Backfill Better Auth verification for existing verified
users: add a Prisma database migration updating User rows with non-null
emailVerified so emailVerifiedBa is true, and update existing seeded/fixture
users in apps/web/playwright/seed.ts to use equivalent values; no direct change
is required in apps/web/app/api/auth/reset-password/route.ts because the stale
production data is corrected by the migration.
- Around line 92-93: Update the migration for the Account model’s updatedAt
column to populate existing rows with a valid timestamp before enforcing the
required NOT NULL constraint. Preserve the schema’s `@updatedAt` behavior while
ensuring historical Account records receive a value during migration.
- Around line 102-114: Update CustomPrismaAdapter’s session
methods—getSessionAndUser(), createSession(), updateSession(), and
deleteSession()—to map the adapter’s sessionToken and expires values to the
Prisma Session model’s token and expiresAt fields. Ensure all session reads,
inserts, updates, and deletes use the renamed fields while preserving the
existing adapter behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 9ed6a64b-f443-4165-9ede-2bbdaa6b428a
📒 Files selected for processing (7)
apps/web/app/api/auth/reset-password/route.tsapps/web/lib/actions/create-user-account.tsapps/web/lib/auth/options.tsapps/web/playwright/seed.tsapps/web/prisma/schema/schema.prismaapps/web/scripts/dev/seed-partner-enrollment.tsapps/web/scripts/dev/seed.ts
|
@coderabbitai made some changes, review the comments |
|
|
9db6c2b to
ed2f4e0
Compare
ed2f4e0 to
32cff31
Compare
Summary by CodeRabbit
Bug Fixes
Authentication