Skip to content

Commit

Permalink
Revert "fix: use tokens from store"
Browse files Browse the repository at this point in the history
  • Loading branch information
shpran authored Apr 21, 2022
1 parent a8f63a3 commit 15227f2
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/core/tokenHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,25 @@ export default function tokenHandlerFactory(options) {
return tokenStore
.expireOldTokens()
.then(() => {
return tokenStore
.getSize()
.then(queueSize => {
if (queueSize > 0) {
// Token available, use it
return getFirstTokenValue();
}

if (!validateTokensOpt || !clientConfigFetched) {
return this
.getClientConfigTokens()
.then(getFirstTokenValue);
}

// No more token options, refresh needed
return Promise.reject(new Error('No tokens available. Please refresh the page.'));
});
if (!clientConfigFetched) {
// Client Config allowed! (first and only time)
return this.getClientConfigTokens()
.then(getFirstTokenValue);
} else {
return tokenStore.getSize()
.then(queueSize => {
if (queueSize > 0) {
// Token available, use it
return getFirstTokenValue();
} else if (!validateTokensOpt) {
return this.getClientConfigTokens()
.then(getFirstTokenValue);
} else {
// No more token options, refresh needed
return Promise.reject(new Error('No tokens available. Please refresh the page.'));
}
});
}
});
},

Expand Down

0 comments on commit 15227f2

Please sign in to comment.