[PR #7583] [MERGED] refactor: remove duplicate session id generation #7419

Closed
opened 2026-03-13 13:35:42 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

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

Base: canaryHead: himself65/2026/01/23/session-id


📝 Commits (6)

📊 Changes

4 files changed (+60 additions, -42 deletions)

View changed files

📝 e2e/smoke/test/redis.spec.ts (+43 -2)
📝 packages/better-auth/src/db/internal-adapter.test.ts (+0 -5)
📝 packages/better-auth/src/db/internal-adapter.ts (+6 -24)
📝 packages/better-auth/src/db/with-hooks.ts (+11 -11)

📄 Description

Fixes: https://github.com/better-auth/better-auth/issues/6993

Summary by cubic

Removed duplicate session ID generation in the internal adapter. Sessions now rely on the database for IDs, header handling is simplified, and create hooks run with the created record.

  • Refactors
    • Removed local sessionId creation; no id is set on new sessions.
    • Simplified header retrieval from the auth context; use headers only.
    • Parse session fields with options; compute ipAddress and userAgent from headers.
    • Updated with-hooks create flow: run main create first when enabled, then pass the created record to customCreateFn; its result becomes the final output.

Written for commit 900ee895ef. 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/7583 **Author:** [@himself65](https://github.com/himself65) **Created:** 1/23/2026 **Status:** ✅ Merged **Merged:** 1/26/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2026/01/23/session-id` --- ### 📝 Commits (6) - [`83a019a`](https://github.com/better-auth/better-auth/commit/83a019af1d7aef4ee5380c998be2307c504a389e) refactor: remove duplicate session id generation - [`a75a504`](https://github.com/better-auth/better-auth/commit/a75a504e25ad048e9b7a25dac153b6582be8268b) fix: no id - [`3d433a2`](https://github.com/better-auth/better-auth/commit/3d433a259555a2f27858f2ab5769947b0e9d30b2) fix: lint - [`d4ce9e8`](https://github.com/better-auth/better-auth/commit/d4ce9e8212e8d1d4287cb779fbed304122b7ca23) chore: test fix - [`ba87056`](https://github.com/better-auth/better-auth/commit/ba870569d58a257359e95b1ceda35d2c33a80ebf) test: fix - [`900ee89`](https://github.com/better-auth/better-auth/commit/900ee895ef4d7685b608ab740039c3b0d23146d2) chore: fix test ### 📊 Changes **4 files changed** (+60 additions, -42 deletions) <details> <summary>View changed files</summary> 📝 `e2e/smoke/test/redis.spec.ts` (+43 -2) 📝 `packages/better-auth/src/db/internal-adapter.test.ts` (+0 -5) 📝 `packages/better-auth/src/db/internal-adapter.ts` (+6 -24) 📝 `packages/better-auth/src/db/with-hooks.ts` (+11 -11) </details> ### 📄 Description Fixes: https://github.com/better-auth/better-auth/issues/6993 <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Removed duplicate session ID generation in the internal adapter. Sessions now rely on the database for IDs, header handling is simplified, and create hooks run with the created record. - **Refactors** - Removed local sessionId creation; no id is set on new sessions. - Simplified header retrieval from the auth context; use headers only. - Parse session fields with options; compute ipAddress and userAgent from headers. - Updated with-hooks create flow: run main create first when enabled, then pass the created record to customCreateFn; its result becomes the final output. <sup>Written for commit 900ee895ef4d7685b608ab740039c3b0d23146d2. 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-03-13 13:35:42 -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#7419