From c577e36b74c87d09fbaed8e50cbebb47c5ecec3c Mon Sep 17 00:00:00 2001 From: sua yoo Date: Tue, 8 Feb 2022 17:22:57 -0800 Subject: [PATCH] add debug for access token --- frontend/src/utils/AuthService.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/frontend/src/utils/AuthService.ts b/frontend/src/utils/AuthService.ts index 76699a25..8b274157 100644 --- a/frontend/src/utils/AuthService.ts +++ b/frontend/src/utils/AuthService.ts @@ -159,11 +159,18 @@ export default class AuthService { private async checkFreshness() { window.clearTimeout(this.timerId); + console.debug("checkFreshness authState:", this._authState); + if (!this._authState) return; const paddedNow = Date.now() + FRESHNESS_TIMER_INTERVAL; if (this._authState.sessionExpiresAt > paddedNow) { if (this._authState.tokenExpiresAt > paddedNow) { + console.debug( + "fresh! restart timer tokenExpiresAt:", + new Date(this._authState.tokenExpiresAt) + ); + console.debug("fresh! restart timer paddedNow:", new Date(paddedNow)); // Restart timer this.timerId = window.setTimeout(() => { this.checkFreshness(); @@ -174,6 +181,15 @@ export default class AuthService { this._authState.headers = auth.headers; this._authState.tokenExpiresAt = auth.tokenExpiresAt; + console.debug( + "refreshed. restart timer tokenExpiresAt:", + new Date(this._authState.tokenExpiresAt) + ); + console.debug( + "refreshed. restart timer paddedNow:", + new Date(paddedNow) + ); + // Restart timer this.timerId = window.setTimeout(() => { this.checkFreshness();