Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

用户登录后设置token的过期时间多乘了1000 (const ex = 7 * 24 * 60 * 60 * 1000;不应该乘以1000) #39

Open
xrascal opened this issue Nov 6, 2023 · 0 comments

Comments

@xrascal
Copy link

xrascal commented Nov 6, 2023

Bug report(问题描述)

用户登录后设置token的过期时间多乘了1000 (const ex = 7 * 24 * 60 * 60 * 1000;不应该乘以1000)。
见 \src\store\modules\user.ts 中的第 58 行:
const ex = 7 * 24 * 60 * 60 * 1000;
Storage.set() 方法的expire参数,看起来是以秒为单位的。

另外,后端提供token的接口,一般会返回一个“过期时间”。比如我的后端接口就会返回一个字段:expireInSeconds。一天就是 24 * 60 * 60 = 86400 秒。所以我会把token的过期时间,设置为 this.setToken(authorization, data?.expireInSeconds);

您现在是硬编码在前端代码里了,并不是真正的过期时间。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant