[PR #4176] [MERGED] fix(oidc-provider): handle string timestamps in user profile claims #13484

Closed
opened 2026-04-13 08:58:07 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4176
Author: @Louis454545
Created: 8/23/2025
Status: Merged
Merged: 8/24/2025
Merged by: @Bekacru

Base: canaryHead: fix/oidc-provider-timestamp-conversion


📝 Commits (1)

  • 4e82109 fix(oidc-provider): handle string timestamps in user profile claims

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/plugins/oidc-provider/index.ts (+1 -1)

📄 Description

Summary

Fixes an error in the OIDC provider when using timestamp fields with { mode: 'string' } configuration. The user.updatedAt.toISOString() call fails when updatedAt is already a string instead of a Date object.

  • Wraps user.updatedAt in new Date() before calling toISOString()
  • Ensures compatibility with both Date objects and string timestamps
  • Follows existing pattern used elsewhere in the codebase for timestamp handling

Test plan

  • Verified the fix resolves the "toISOString is not a function" error
  • Confirmed existing tests still pass with the change
  • Validated type safety - new Date() constructor accepts both Date and string inputs
  • Follows existing patterns in the codebase (line 812 already uses this approach)

Fixes #4159


Summary by cubic

Fixes a crash in the OIDC provider when updatedAt is a string (timestamp mode: 'string') by converting it to a Date before calling toISOString. Ensures updated_at in user profile claims is always valid. Fixes #4159.

  • Bug Fixes
    • Wrap user.updatedAt with new Date(...) before toISOString()
    • Supports both Date objects and string timestamps

🔄 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/4176 **Author:** [@Louis454545](https://github.com/Louis454545) **Created:** 8/23/2025 **Status:** ✅ Merged **Merged:** 8/24/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/oidc-provider-timestamp-conversion` --- ### 📝 Commits (1) - [`4e82109`](https://github.com/better-auth/better-auth/commit/4e82109be1cf3fc7252f519c88065b6930600f85) fix(oidc-provider): handle string timestamps in user profile claims ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/oidc-provider/index.ts` (+1 -1) </details> ### 📄 Description ## Summary Fixes an error in the OIDC provider when using timestamp fields with `{ mode: 'string' }` configuration. The `user.updatedAt.toISOString()` call fails when `updatedAt` is already a string instead of a Date object. - Wraps `user.updatedAt` in `new Date()` before calling `toISOString()` - Ensures compatibility with both Date objects and string timestamps - Follows existing pattern used elsewhere in the codebase for timestamp handling ## Test plan - [x] Verified the fix resolves the "toISOString is not a function" error - [x] Confirmed existing tests still pass with the change - [x] Validated type safety - `new Date()` constructor accepts both Date and string inputs - [x] Follows existing patterns in the codebase (line 812 already uses this approach) Fixes #4159 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes a crash in the OIDC provider when updatedAt is a string (timestamp mode: 'string') by converting it to a Date before calling toISOString. Ensures updated_at in user profile claims is always valid. Fixes #4159. - **Bug Fixes** - Wrap user.updatedAt with new Date(...) before toISOString() - Supports both Date objects and string timestamps <!-- 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-13 08:58:07 -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#13484