Skip to content

Commit

Permalink
Merge pull request #137 from oat-sa/hotfix-1.16.3.1/oatsd-1783/get-to…
Browse files Browse the repository at this point in the history
…kens-from-store

[1.16.3-1][Hotfix][OATSD-1783] Use tokens from store
  • Loading branch information
shpran authored Apr 13, 2022
2 parents aab809f + 7697fc4 commit af6bcf6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 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.16.3",
"version": "1.16.3-1",
"displayName": "TAO Core SDK",
"description": "Core libraries of TAO",
"homepage": "https://github.com/oat-sa/tao-core-sdk-fe#readme",
Expand Down
36 changes: 17 additions & 19 deletions src/core/tokenHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,23 @@ export default function tokenHandlerFactory(options) {
return tokenStore
.expireOldTokens()
.then(() => {
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.'));
}
});
}
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.'));
});
});
},

Expand Down

0 comments on commit af6bcf6

Please sign in to comment.