[PR #5885] type ( refactor ) #14543

Closed
opened 2026-04-13 09:31:29 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/5885

State: closed
Merged: No


i created an ensure email verification helper, it ensure email verification is enabled in options and return the object, it helps make the send verification email fn function simpler and more efficient, i feel using helpers gives code a better structure.


Summary by cubic

Centralized email verification checks and URL building, added secure OAuth refresh token handling, and cleared stale session data on expiry. Improved callback URL handling across reset-password, sign-in, sign-up, change-email, and delete-user, plus hardened OAuth state parsing and fixed update hooks.

  • Refactors

    • Email verification: applied ensureEmailVerificationEnabled across routes, switched to zod/v4, and centralized buildVerificationUrl.
    • OAuth/linking/cookies/migrations: decrypt refreshToken before refresh; clear session-data cookie on missing/expired session; include callback URLs in OAuth state and optionally store account cookie after linking; normalize cross-subdomain cookie domain; chunk session/account cookies by byte length; arrays stored as JSON and avoid NOT NULL without defaults; with-hooks: pass actualData to update.before and reuse adapter instance.
    • Sign-up/update-user: explicit schema and originCheck-decode callbackURL; lowercase email for lookup/create/token; block restricted fields and validate name/image.
  • Bug Fixes

    • Delete-user: fix session freshness check to prevent false “expired” errors.
    • Cookies: split combined Set-Cookie when Expires contains commas.
    • Internal adapter: correct session TTL math and avoid premature loop exits.
    • OAuth state: fix cookie maxAge units and handle bad JSON with safe redirect.

Written for commit 0841e67540. Summary will update on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5885 **State:** closed **Merged:** No --- i created an ensure email verification helper, it ensure email verification is enabled in options and return the object, it helps make the send verification email fn function simpler and more efficient, i feel using helpers gives code a better structure. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Centralized email verification checks and URL building, added secure OAuth refresh token handling, and cleared stale session data on expiry. Improved callback URL handling across reset-password, sign-in, sign-up, change-email, and delete-user, plus hardened OAuth state parsing and fixed update hooks. - **Refactors** - Email verification: applied ensureEmailVerificationEnabled across routes, switched to zod/v4, and centralized buildVerificationUrl. - OAuth/linking/cookies/migrations: decrypt refreshToken before refresh; clear session-data cookie on missing/expired session; include callback URLs in OAuth state and optionally store account cookie after linking; normalize cross-subdomain cookie domain; chunk session/account cookies by byte length; arrays stored as JSON and avoid NOT NULL without defaults; with-hooks: pass actualData to update.before and reuse adapter instance. - Sign-up/update-user: explicit schema and originCheck-decode callbackURL; lowercase email for lookup/create/token; block restricted fields and validate name/image. - **Bug Fixes** - Delete-user: fix session freshness check to prevent false “expired” errors. - Cookies: split combined Set-Cookie when Expires contains commas. - Internal adapter: correct session TTL math and avoid premature loop exits. - OAuth state: fix cookie maxAge units and handle bad JSON with safe redirect. <sup>Written for commit 0841e67540890fac404aaeaf91dc2608d2d4f0f0. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 09:31:29 -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#14543