[PR #4522] [MERGED] fix: refresh secondary storage sessions on user update #5425

Closed
opened 2026-03-13 12:22:24 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4522
Author: @frectonz
Created: 9/8/2025
Status: Merged
Merged: 9/17/2025
Merged by: @Bekacru

Base: canaryHead: fix/refresh-sessions-on-user-update


📝 Commits (2)

  • 19000e7 test: email verification should update all user sessions
  • 2b32e9e fix: refresh all user sessions on update

📊 Changes

2 files changed (+96 additions, -35 deletions)

View changed files

📝 packages/better-auth/src/api/routes/email-verification.test.ts (+59 -0)
📝 packages/better-auth/src/db/internal-adapter.ts (+37 -35)

📄 Description

The secondaryStorage sessions were not being updated when a user update was performed using the updateUserByEmail function. This PR fixes that issue.


Summary by cubic

Fixes stale secondaryStorage sessions after user updates. All active cached sessions now reflect the latest user fields (e.g., email, emailVerified).

  • Bug Fixes

    • Refresh all active secondaryStorage sessions after updateUser and updateUserByEmail.
    • Added test to ensure email verification sets emailVerified=true across multiple active sessions.
  • Refactors

    • Extracted refreshUserSessions helper to deduplicate session cache update logic.

🔄 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/4522 **Author:** [@frectonz](https://github.com/frectonz) **Created:** 9/8/2025 **Status:** ✅ Merged **Merged:** 9/17/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/refresh-sessions-on-user-update` --- ### 📝 Commits (2) - [`19000e7`](https://github.com/better-auth/better-auth/commit/19000e7ab04debcf053f2f9cda4c3e94e649a282) test: email verification should update all user sessions - [`2b32e9e`](https://github.com/better-auth/better-auth/commit/2b32e9ef18175651831ec5b0697bc0731039cb7f) fix: refresh all user sessions on update ### 📊 Changes **2 files changed** (+96 additions, -35 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/email-verification.test.ts` (+59 -0) 📝 `packages/better-auth/src/db/internal-adapter.ts` (+37 -35) </details> ### 📄 Description The `secondaryStorage` sessions were not being updated when a user update was performed using the `updateUserByEmail` function. This PR fixes that issue. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes stale secondaryStorage sessions after user updates. All active cached sessions now reflect the latest user fields (e.g., email, emailVerified). - **Bug Fixes** - Refresh all active secondaryStorage sessions after updateUser and updateUserByEmail. - Added test to ensure email verification sets emailVerified=true across multiple active sessions. - **Refactors** - Extracted refreshUserSessions helper to deduplicate session cache update logic. <!-- 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-03-13 12:22:24 -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#5425