Skip to content

Commit

Permalink
Merge pull request #73 from oat-sa/fix/TBD-48/initialize-token-pool-b…
Browse files Browse the repository at this point in the history
…y-configuration-values-on-first-access

Fix TBD-48 initialize token pool with configuration values on first access
  • Loading branch information
Juan Luis Gutierrez Dos Santos authored Aug 7, 2020
2 parents 0cea5f0 + eafcdd3 commit 4c84a33
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oat-sa/tao-core-sdk",
"version": "1.6.1",
"version": "1.6.2",
"displayName": "TAO Core SDK",
"description": "Core libraries of TAO",
"homepage": "https://github.com/oat-sa/tao-core-sdk-fe#readme",
Expand Down
26 changes: 15 additions & 11 deletions src/core/tokenHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,25 @@ export default function tokenHandlerFactory(options) {
// Some async checks before we go for the token:
return tokenStore
.expireOldTokens()
.then(() => tokenStore.getSize())
.then(queueSize => {
if (queueSize > 0) {
// Token available, use it
return getFirstTokenValue();
} else if (!validateTokensOpt) {
return this.getClientConfigTokens()
.then(getFirstTokenValue);
}else if (!clientConfigFetched) {
.then(() => {
if (!clientConfigFetched) {
// Client Config allowed! (first and only time)
return this.getClientConfigTokens()
.then(getFirstTokenValue);
} else {
// No more token options, refresh needed
return Promise.reject(new Error('No tokens available. Please refresh the page.'));
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 4c84a33

Please sign in to comment.