From 4545643be2e4892ac5aec9cb3fc4d32adc89fde1 Mon Sep 17 00:00:00 2001 From: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com> Date: Tue, 8 Feb 2022 11:43:42 -0600 Subject: [PATCH] UI: Add check for renewal time before triggering renew-self (#13950) --- changelog/13950.txt | 3 +++ ui/app/services/auth.js | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 changelog/13950.txt diff --git a/changelog/13950.txt b/changelog/13950.txt new file mode 100644 index 000000000..02ed84d1c --- /dev/null +++ b/changelog/13950.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: trigger token renewal if inactive and half of TTL has passed +``` \ No newline at end of file diff --git a/ui/app/services/auth.js b/ui/app/services/auth.js index b2a1a99ff..ee1fb727c 100644 --- a/ui/app/services/auth.js +++ b/ui/app/services/auth.js @@ -292,9 +292,10 @@ export default Service.extend({ }, setLastFetch(timestamp) { + const now = this.now(); this.set('lastFetch', timestamp); - // if expiration was allowed we want to go ahead and renew here - if (this.allowExpiration) { + // if expiration was allowed and we're over half the ttl we want to go ahead and renew here + if (this.allowExpiration && now >= this.renewAfterEpoch) { this.renew(); } this.set('allowExpiration', false);