diff options
author | 2022-07-02 20:55:59 +0100 | |
---|---|---|
committer | 2022-07-02 20:55:59 +0100 | |
commit | deb96400919540b3c8fbb1d89f6eefe89d715b09 (patch) | |
tree | 43b4b68f963a90266b68ad7e87186956bd4c6f51 /src/api | |
parent | Merge pull request #474 from python-discord/display-test-failures (diff) |
Base refresh timeout on diff from current time
Previously the logic was using the expiry date's unix timestamp as if it was a number of ms until it expired. This caused the timeout to be far after the actual token expiry.
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/auth.ts | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/api/auth.ts b/src/api/auth.ts index 7f01b9d..de6210e 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -204,7 +204,7 @@ export async function refreshBackendJWT(): Promise<boolean> { cookies.set(CookieNames.Username, response.data.username, {sameSite: "strict", secure: PRODUCTION, path: "/", expires: new Date(3000, 1)}); const expiry = Date.parse(response.data.expiry); - setTimeout(refreshBackendJWT, (expiry * 0.9)); + setTimeout(refreshBackendJWT, ((expiry - Date.now()) / 1000 * 0.9)); }).catch(() => { pass = false; cookies.remove(CookieNames.Scopes); |