[PR #5914] refactor: initFn for defineRequestState #14564

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

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

State: closed
Merged: Yes


Summary by cubic

Refactored request-scoped state to use an init function with automatic defaults, simplifying the API and fixing OIDC login prompt handling without leaking state between requests.

  • Refactors

    • Replaced defineRequestState(schema) with defineRequestState(initFn); get() auto-initializes.
    • Store keys are now unique ref objects (exposed via ref).
    • Removed schema-based validation and Zod usage.
    • OAuth state defaults to null; prompt set defaults to an empty Set.
    • OIDC login prompt flow now uses request state (get/setPromptHandled) instead of ctx.context flags.
  • Migration

    • Replace defineRequestState(schema) with defineRequestState(() => initialValue).
    • Perform your own validation if needed (schema validation removed).
    • Update getOAuthState consumers to handle null results.
    • Use getPromptHandled/setPromptHandled instead of ctx.context.oidcLoginPromptHandled.

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

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5914 **State:** closed **Merged:** Yes --- <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Refactored request-scoped state to use an init function with automatic defaults, simplifying the API and fixing OIDC login prompt handling without leaking state between requests. - **Refactors** - Replaced defineRequestState(schema) with defineRequestState(initFn); get() auto-initializes. - Store keys are now unique ref objects (exposed via ref). - Removed schema-based validation and Zod usage. - OAuth state defaults to null; prompt set defaults to an empty Set. - OIDC login prompt flow now uses request state (get/setPromptHandled) instead of ctx.context flags. - **Migration** - Replace defineRequestState(schema) with defineRequestState(() => initialValue). - Perform your own validation if needed (schema validation removed). - Update getOAuthState consumers to handle null results. - Use getPromptHandled/setPromptHandled instead of ctx.context.oidcLoginPromptHandled. <sup>Written for commit 56273971477794b5e8a4d66e27b0d21bb8b7cbd7. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 09:31:48 -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#14564