Skip to content

Commit

Permalink
fix: ahead of 10 minutes refresh token (#94)
Browse files Browse the repository at this point in the history
Signed-off-by: liuying <[email protected]>

Signed-off-by: liuying <[email protected]>
  • Loading branch information
lysign authored Aug 13, 2022
1 parent 2c65e89 commit f02ef21
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ module.exports = methods.reduce(

async function checkToken(callback) {
const token = getLocalStorageItem('token') || {};
const { expires = '', expire = '' } = token;
const { expires = '' } = token;
if (expires) {
const current = new Date().getTime();

// eslint-disable-next-line no-mixed-operators
const TIME_DELAY = expire - 10 * 1000;
// ahead of 10 minutes refresh token, aviod time difference between client and server
const TIME_DELAY = 10 * 60 * 1000;
if (expires <= current + TIME_DELAY) {
const resp = await rootStore.getNewToken(token);

Expand Down

0 comments on commit f02ef21

Please sign in to comment.