Skip to content

Commit

Permalink
Merge pull request #140 from oat-sa/revert-135-fix/oatsd-1783/get-tok…
Browse files Browse the repository at this point in the history
…ens-from-store

Revert "fix: use tokens from store"
  • Loading branch information
shpran committed Apr 21, 2022
2 parents a8f63a3 + af299ec commit 3caea57
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 3caea57

Please sign in to comment.