Fix expired calculation to be 6 months from now instead of setting to June

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 07:39:52 +08:00
parent 905f546227
commit 43283aab95
2 changed files with 14 additions and 1 deletions

View File

@@ -17,7 +17,7 @@ export default defineStore('loginStore', {
userData: {}, userData: {},
isLoggedIn: false, isLoggedIn: false,
rememberedReturnToUrl: "", rememberedReturnToUrl: "",
expired: new Date().setMonth(6), // 設定 Refresh Token 的到期日為半年後 expired: (() => { const d = new Date(); d.setMonth(d.getMonth() + 6); return d.getTime(); })(), // 設定 Refresh Token 的到期日為半年後
}), }),
actions: { actions: {
/** /**

View File

@@ -143,4 +143,17 @@ describe('loginStore', () => {
store.setIsLoggedIn(true); store.setIsLoggedIn(true);
expect(store.isLoggedIn).toBe(true); expect(store.isLoggedIn).toBe(true);
}); });
describe('expired', () => {
it('is approximately 6 months in the future', () => {
const now = new Date();
const sixMonthsLater = new Date(now);
sixMonthsLater.setMonth(sixMonthsLater.getMonth() + 6);
const expiredDate = new Date(store.expired);
// Allow 1 day tolerance
const diffMs = Math.abs(expiredDate.getTime() - sixMonthsLater.getTime());
expect(diffMs).toBeLessThan(24 * 60 * 60 * 1000);
});
});
}); });