mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #5599] [MERGED] fix(settings): normalize API token timestamps #5922
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#5922
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/5599
Author: @Tomilla
Created: 6/27/2026
Status: ✅ Merged
Merged: 6/27/2026
Merged by: @MHSanaei
Base:
main← Head:fix/api-token-timestamps📝 Commits (2)
e56e317fix(settings): normalize API token timestamps98f4c12refactor(api-token): share timestamp threshold📊 Changes
7 files changed (+141 additions, -4 deletions)
View changed files
📝
frontend/src/pages/settings/SecurityTab.tsx(+8 -2)➕
frontend/src/test/api-token-date.test.tsx(+36 -0)➕
internal/database/api_token_timestamp_test.go(+49 -0)📝
internal/database/db.go(+12 -0)📝
internal/database/model/model.go(+5 -1)📝
internal/web/service/panel/api_token.go(+8 -1)➕
internal/web/service/panel/api_token_test.go(+23 -0)📄 Description
Summary
Fix incorrect API-token creation dates in Panel Settings → Authentication → API Token. API-token timestamps now consistently use Unix seconds while remaining compatible with legacy millisecond values.
Why
The API contract and frontend expected
ApiToken.createdAtin Unix seconds, but the database model usedautoCreateTime:milli.For example, the backend returned:
1782485394270The frontend multiplied this value by 1,000 again, producing a date thousands of years in the future instead of:
06/26/2026, 22:49:54This PR restores the documented seconds-based contract and safely handles data created by affected versions.
Type of change
Areas affected
How was this tested?
Automated validation
The following commands passed locally:
go build ./...go test ./...npm run lintnpm run typechecknpm run test— 40 test files and 589 tests passednpm run buildAdded regression coverage
17824853941782485394270Real database test
Tested locally with a copy of an existing
x-ui.dbcontaining:created_at = 1782485394270After backend startup, the copied database contained:
created_at = 1782485394The authenticated endpoint:
GET /panel/api/setting/apiTokensreturned:
The frontend was tested through the Vite development server in a Chromium-based browser.
On Panel Settings → Authentication → API Token, the token rendered as:
central-panel — 06/26/2026, 22:49:54The original database was not modified.
Screenshots / recordings
Screenshot of Authentication → API Token Datetime Bug:

Fixed:

Breaking changes
None expected.
createdAtusing Unix seconds.Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.