[PR #3704] [MERGED] fix: cast dates from session to Date when using date methods #21863

Closed
opened 2026-04-15 20:39:44 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3704
Author: @erquhart
Created: 7/30/2025
Status: Merged
Merged: 8/1/2025
Merged by: @Bekacru

Base: mainHead: cast-session-dates


📝 Commits (2)

  • 311ed5c fix: cast dates from session to Date when using date methods
  • 2b6bd64 add changeset

📊 Changes

6 files changed (+14 additions, -5 deletions)

View changed files

.changeset/breezy-rice-grin.md (+5 -0)
📝 packages/better-auth/src/api/routes/update-user.ts (+1 -1)
📝 packages/better-auth/src/plugins/mcp/authorize.ts (+1 -1)
📝 packages/better-auth/src/plugins/mcp/index.ts (+3 -1)
📝 packages/better-auth/src/plugins/oidc-provider/authorize.ts (+1 -1)
📝 packages/better-auth/src/plugins/oidc-provider/index.ts (+3 -1)

📄 Description

Follow up from https://github.com/better-auth/better-auth/pull/3611, wrongly assumed the context session was exempt from this issue.


Summary by cubic

Fixed date handling in session objects by casting session.createdAt to a Date before using date methods. This prevents errors when session.createdAt is not already a Date instance.


🔄 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/3704 **Author:** [@erquhart](https://github.com/erquhart) **Created:** 7/30/2025 **Status:** ✅ Merged **Merged:** 8/1/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `cast-session-dates` --- ### 📝 Commits (2) - [`311ed5c`](https://github.com/better-auth/better-auth/commit/311ed5caa4be85406915813e59cde7a60ee1a15f) fix: cast dates from session to Date when using date methods - [`2b6bd64`](https://github.com/better-auth/better-auth/commit/2b6bd6418349ad5ab38c8277bfe5ecbd24dc83d9) add changeset ### 📊 Changes **6 files changed** (+14 additions, -5 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/breezy-rice-grin.md` (+5 -0) 📝 `packages/better-auth/src/api/routes/update-user.ts` (+1 -1) 📝 `packages/better-auth/src/plugins/mcp/authorize.ts` (+1 -1) 📝 `packages/better-auth/src/plugins/mcp/index.ts` (+3 -1) 📝 `packages/better-auth/src/plugins/oidc-provider/authorize.ts` (+1 -1) 📝 `packages/better-auth/src/plugins/oidc-provider/index.ts` (+3 -1) </details> ### 📄 Description Follow up from https://github.com/better-auth/better-auth/pull/3611, wrongly assumed the context session was exempt from this issue. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixed date handling in session objects by casting session.createdAt to a Date before using date methods. This prevents errors when session.createdAt is not already a Date instance. <!-- 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 20:39:44 -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#21863