UI: Add check for renewal time before triggering renew-self (#13950)

This commit is contained in:
Chelsea Shaw 2022-02-08 11:43:42 -06:00 committed by GitHub
parent 5804da7490
commit 4545643be2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

3
changelog/13950.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
ui: trigger token renewal if inactive and half of TTL has passed
```

View File

@ -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);