[PR #562] [CLOSED] Reset password expiration failed and date converted to timestamp to add precision #3366

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/562
Author: @Limerio
Created: 11/17/2024
Status: Closed

Base: mainHead: reset-password-expiration


📝 Commits (2)

  • e8993e3 fix: change the date format to timestamp to add precision
  • 5b9db56 fix: error invalid token cause by the none precision of the expiresAt field, and new Date() use the timezone of the actual machine

📊 Changes

2 files changed (+13 additions, -6 deletions)

View changed files

📝 packages/better-auth/src/api/routes/forget-password.ts (+8 -4)
📝 packages/better-auth/src/db/get-migration.ts (+5 -2)

📄 Description

Initially, I was investigating why the format of expiresAt is a date (format: YYYY-MM-DD). What seemed unusual was that while the expiration time is set to one hour later, the expiresAt field doesn't include any time information. To address this, I attempted to convert it to a timestamp (which I think, it's not the best approach, as it converts all dates to timestamps – feel free to contribute and improve this solution). However, I encountered another issue: when you call new Date(), it returns a date in your machine's local timezone rather than UTC. Therefore, I needed to convert it to UTC to ensure that both the timestamp and UTC time were in the same timezone.


🔄 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/562 **Author:** [@Limerio](https://github.com/Limerio) **Created:** 11/17/2024 **Status:** ❌ Closed **Base:** `main` ← **Head:** `reset-password-expiration` --- ### 📝 Commits (2) - [`e8993e3`](https://github.com/better-auth/better-auth/commit/e8993e30ce64c14a3611e085362841d0285d8c56) fix: change the date format to timestamp to add precision - [`5b9db56`](https://github.com/better-auth/better-auth/commit/5b9db565ce16f577d0f3455bbe56cc297018037c) fix: error invalid token cause by the none precision of the expiresAt field, and new Date() use the timezone of the actual machine ### 📊 Changes **2 files changed** (+13 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/forget-password.ts` (+8 -4) 📝 `packages/better-auth/src/db/get-migration.ts` (+5 -2) </details> ### 📄 Description Initially, I was investigating why the format of expiresAt is a date (format: `YYYY-MM-DD`). What seemed unusual was that while the expiration time is set to one hour later, the expiresAt field doesn't include any time information. To address this, I attempted to convert it to a timestamp (which I think, it's not the best approach, as it converts all dates to timestamps – feel free to contribute and improve this solution). However, I encountered another issue: when you call `new Date()`, it returns a date in your machine's local timezone rather than UTC. Therefore, I needed to convert it to UTC to ensure that both the timestamp and UTC time were in the same timezone. --- <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 10:51: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#3366