[PR #6573] [CLOSED] refactor: use verification table instead of jwt for email verification #23655

Closed
opened 2026-04-15 21:53:33 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6573
Author: @jslno
Created: 12/6/2025
Status: Closed

Base: canaryHead: 12-06-2025/refactor-email-verification-token


📝 Commits (9)

  • 7f77e23 refactor: use verification table instead of jwt for email verification
  • b398951 fix: expiresAt check
  • 707f7e7 chore: fix tests
  • 255c07d chore: delete ott after usage
  • 843694f chore: cleanup
  • 2f48bfb chore: fix linting
  • c594d62 Update email-verification.ts
  • e3ae881 trigger ci
  • 3e1f062 Merge branch 'canary' into 12-06-2025/refactor-email-verification-token

📊 Changes

7 files changed (+99 additions, -34 deletions)

View changed files

📝 packages/better-auth/src/api/routes/email-verification.test.ts (+11 -0)
📝 packages/better-auth/src/api/routes/email-verification.ts (+81 -27)
📝 packages/better-auth/src/api/routes/sign-in.ts (+1 -1)
📝 packages/better-auth/src/api/routes/sign-up.ts (+1 -1)
📝 packages/better-auth/src/api/routes/update-user.ts (+3 -3)
📝 packages/better-auth/src/oauth2/link-account.ts (+1 -1)
📝 packages/better-auth/src/plugins/username/index.ts (+1 -1)

📄 Description

Summary by cubic

Refactor email verification to use a database-backed verification table instead of JWT. This enables revocation and simplifies token handling across sign-in, sign-up, change-email, and OAuth flows.

  • Refactors

    • Store tokens via internalAdapter.createVerificationValue with an "email-verification:" prefix and expiresAt.
    • Replace jwtVerify with table lookup and JSON payload parsing.
    • Update send/verify flows to call createEmailVerificationToken(ctx, ...) in email, sign-in, sign-up, change-email, OAuth link, and username plugin.
    • Delete tokens after use and when email is unknown to prevent enumeration.
    • Remove jose/JWT usage and secret-based signing.
  • Migration

    • Ensure the adapter supports the verification table API (create/find/delete).
    • Email templates should use the returned token (without the prefix). No client-facing API changes expected.

Written for commit e3ae8811f1. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/6573 **Author:** [@jslno](https://github.com/jslno) **Created:** 12/6/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `12-06-2025/refactor-email-verification-token` --- ### 📝 Commits (9) - [`7f77e23`](https://github.com/better-auth/better-auth/commit/7f77e2398b8b8e03879a8887174adddbdd751c04) refactor: use verification table instead of jwt for email verification - [`b398951`](https://github.com/better-auth/better-auth/commit/b398951b92ff12714281157c5c199fcc06be7d14) fix: expiresAt check - [`707f7e7`](https://github.com/better-auth/better-auth/commit/707f7e7a467b78be6d6d3c3362dcce3537b0dbd4) chore: fix tests - [`255c07d`](https://github.com/better-auth/better-auth/commit/255c07dd107425d89a32e5121fa4438de66f4202) chore: delete ott after usage - [`843694f`](https://github.com/better-auth/better-auth/commit/843694f56cecb1461e6a8ad130c53adcfc4f69de) chore: cleanup - [`2f48bfb`](https://github.com/better-auth/better-auth/commit/2f48bfb5732d6cbb2a0c3d1a32451ed5047b4ddc) chore: fix linting - [`c594d62`](https://github.com/better-auth/better-auth/commit/c594d624e7fa132a207f83ccc24b435ec4b81853) Update email-verification.ts - [`e3ae881`](https://github.com/better-auth/better-auth/commit/e3ae8811f16d4865016cfa9cbbbfca490445ce29) trigger ci - [`3e1f062`](https://github.com/better-auth/better-auth/commit/3e1f062cc1964443f13a71d47926d47c8365ac57) Merge branch 'canary' into 12-06-2025/refactor-email-verification-token ### 📊 Changes **7 files changed** (+99 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/email-verification.test.ts` (+11 -0) 📝 `packages/better-auth/src/api/routes/email-verification.ts` (+81 -27) 📝 `packages/better-auth/src/api/routes/sign-in.ts` (+1 -1) 📝 `packages/better-auth/src/api/routes/sign-up.ts` (+1 -1) 📝 `packages/better-auth/src/api/routes/update-user.ts` (+3 -3) 📝 `packages/better-auth/src/oauth2/link-account.ts` (+1 -1) 📝 `packages/better-auth/src/plugins/username/index.ts` (+1 -1) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Refactor email verification to use a database-backed verification table instead of JWT. This enables revocation and simplifies token handling across sign-in, sign-up, change-email, and OAuth flows. - **Refactors** - Store tokens via internalAdapter.createVerificationValue with an "email-verification:" prefix and expiresAt. - Replace jwtVerify with table lookup and JSON payload parsing. - Update send/verify flows to call createEmailVerificationToken(ctx, ...) in email, sign-in, sign-up, change-email, OAuth link, and username plugin. - Delete tokens after use and when email is unknown to prevent enumeration. - Remove jose/JWT usage and secret-based signing. - **Migration** - Ensure the adapter supports the verification table API (create/find/delete). - Email templates should use the returned token (without the prefix). No client-facing API changes expected. <sup>Written for commit e3ae8811f16d4865016cfa9cbbbfca490445ce29. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 21:53:33 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#23655