Sitelet https://github.com/dubinc/dub/pull/4284
Skip to content

[1] Better Auth - Schema + Compatibility - #4284

Open
devkiran wants to merge 12 commits into
mainfrom
better-auth-1
Open

[1] Better Auth - Schema + Compatibility#4284
devkiran wants to merge 12 commits into
mainfrom
better-auth-1

Conversation

@devkiran

@devkiran devkiran commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes

    • Improved account verification handling during sign-up and password resets.
    • Verified account status is now preserved consistently across authentication flows.
  • Authentication

    • Enhanced support for account updates, sessions, verification tokens, and authentication metadata.
    • Improved compatibility with current authentication behavior while preserving password reset and account recovery functionality.
    • Added more consistent tracking for verified accounts created through setup and testing workflows.

@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dub Ready Ready Preview Aug 18, 2026 9:22pm

Request Review

@devkiran
devkiran requested a review from steven-tey August 7, 2026 09:13
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9f5c8094-5dee-446e-b86e-254a804907a4

📥 Commits

Reviewing files that changed from the base of the PR and between a864cd2 and 782d942.

📒 Files selected for processing (1)
  • apps/web/playwright/seed.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/playwright/seed.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The PR adds Better Auth-compatible Prisma fields and models. It updates the authentication adapter and password reset flow to persist emailVerifiedBa. Account creation and seed scripts now set the flag for verified users.

Changes

Authentication verification support

Layer / File(s) Summary
Authentication schema contract
apps/web/prisma/schema/schema.prisma
The User model adds verification metadata. Account, Session, and Verification support Better Auth fields, timestamps, relations, indexes, and uniqueness constraints.
Authentication adapter persistence
apps/web/lib/auth/options.ts
The custom Prisma adapter persists verification fields during user creation and updates users by ID through updateUser.
Verification flag propagation
apps/web/app/api/auth/reset-password/route.ts, apps/web/lib/actions/create-user-account.ts, apps/web/playwright/seed.ts, apps/web/scripts/dev/seed-partner-enrollment.ts, apps/web/scripts/dev/seed.ts
Password reset, application account creation, and seed user creation now set emailVerifiedBa: true.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 782d9

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
Loading

Suggested reviewers: steven-tey

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main changes: Better Auth schema updates and compatibility changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch better-auth-1

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3f68d6a and a843996.

📒 Files selected for processing (7)
  • apps/web/app/api/auth/reset-password/route.ts
  • apps/web/lib/actions/create-user-account.ts
  • apps/web/lib/auth/options.ts
  • apps/web/playwright/seed.ts
  • apps/web/prisma/schema/schema.prisma
  • apps/web/scripts/dev/seed-partner-enrollment.ts
  • apps/web/scripts/dev/seed.ts

Comment thread apps/web/lib/auth/options.ts
Comment thread apps/web/prisma/schema/schema.prisma
Comment thread apps/web/prisma/schema/schema.prisma Outdated
Comment thread apps/web/prisma/schema/schema.prisma
@devkiran

devkiran commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai made some changes, review the comments

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

@devkiran I will review the updated changes and the existing review comments.

⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@devkiran devkiran changed the title Better Auth - Schema + Compatibility [1] Better Auth - Schema + Compatibility Aug 13, 2026
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.

2 participants