[PR #7576] [MERGED] fix: refresh account_data cookie when session is refreshed #24314

Closed
opened 2026-04-15 22:18:11 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7576
Author: @bytaesu
Created: 1/23/2026
Status: Merged
Merged: 1/23/2026
Merged by: @himself65

Base: canaryHead: 2026-01-24/fix/account-cookie-refresh


📝 Commits (9)

📊 Changes

5 files changed (+335 additions, -125 deletions)

View changed files

📝 packages/better-auth/src/api/routes/account.test.ts (+204 -0)
📝 packages/better-auth/src/cookies/index.ts (+106 -104)
📝 packages/better-auth/src/plugins/organization/adapter.ts (+1 -20)
📝 packages/core/src/types/index.ts (+4 -1)
packages/core/src/utils/db.ts (+20 -0)

📄 Description

Note

In stateless mode, storeAccountCookie is enabled by default

Related to https://discord.com/channels/1288403910284935179/1443514112205262960/1463820896316948563


Summary by cubic

Refreshes the account_data cookie whenever the session cookie is refreshed to keep both in sync. Prevents stale account info, including in stateless mode where storeAccountCookie is enabled by default.

  • Bug Fixes

    • Refresh account_data after session cookie cache updates (compact/jwt/jwe strategies).
    • Add tests for standard and stateless flows to verify cookie refresh.
  • Refactors

    • Use getAccountCookie and setAccountCookie helpers to manage account cookie updates.
    • Centralize output field filtering in core utils (filterOutputFields) and reuse in cookies and organization plugin.

Written for commit ec6ab2bead. Summary will update 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/7576 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 1/23/2026 **Status:** ✅ Merged **Merged:** 1/23/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2026-01-24/fix/account-cookie-refresh` --- ### 📝 Commits (9) - [`96c0b9d`](https://github.com/better-auth/better-auth/commit/96c0b9dfd4dc77a3e8603e21cf1629f674b2b92c) fix: refresh account_data cookie when session is refreshed - [`7599a0b`](https://github.com/better-auth/better-auth/commit/7599a0bcfb08cab4a65c819f1b9a8f77769eeb82) refactor: use early return - [`defeefb`](https://github.com/better-auth/better-auth/commit/defeefb2b001a38422c9ff34504c1f0aac41f745) chore: restore comments - [`7dc0fec`](https://github.com/better-auth/better-auth/commit/7dc0feccfd3342e458b471a27319292e84d333e8) fix: simplify code - [`d02d547`](https://github.com/better-auth/better-auth/commit/d02d54749d385d51b90f4d3acc7fd4e583440b76) feat: refactor code - [`0522dcb`](https://github.com/better-auth/better-auth/commit/0522dcb73bf12321e07fa27e237b2f399fc3cd38) fix: isPromise - [`9b3f5e9`](https://github.com/better-auth/better-auth/commit/9b3f5e9f3e5cbeb3ca1371895eef0f971ff46e5b) fix: rename - [`bbd6205`](https://github.com/better-auth/better-auth/commit/bbd6205accebdf820b51883c4c3442fcd15ad987) Revert "feat: refactor code" - [`ec6ab2b`](https://github.com/better-auth/better-auth/commit/ec6ab2bead49c6cb87f918380207ea39a7ef6f3a) Revert ### 📊 Changes **5 files changed** (+335 additions, -125 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/account.test.ts` (+204 -0) 📝 `packages/better-auth/src/cookies/index.ts` (+106 -104) 📝 `packages/better-auth/src/plugins/organization/adapter.ts` (+1 -20) 📝 `packages/core/src/types/index.ts` (+4 -1) ➕ `packages/core/src/utils/db.ts` (+20 -0) </details> ### 📄 Description > [!NOTE] > In stateless mode, `storeAccountCookie` is enabled by default Related to https://discord.com/channels/1288403910284935179/1443514112205262960/1463820896316948563 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Refreshes the account_data cookie whenever the session cookie is refreshed to keep both in sync. Prevents stale account info, including in stateless mode where storeAccountCookie is enabled by default. - **Bug Fixes** - Refresh account_data after session cookie cache updates (compact/jwt/jwe strategies). - Add tests for standard and stateless flows to verify cookie refresh. - **Refactors** - Use getAccountCookie and setAccountCookie helpers to manage account cookie updates. - Centralize output field filtering in core utils (filterOutputFields) and reuse in cookies and organization plugin. <sup>Written for commit ec6ab2bead49c6cb87f918380207ea39a7ef6f3a. Summary will update 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 22:18:11 -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#24314