fix(core.gbapp): #387 adding /setupSecurity multiple tokens. Refresh token fix. @othonlima @christopherdecastilho.
This commit is contained in:
parent
4bd2340613
commit
84858db975
1 changed files with 6 additions and 2 deletions
|
@ -611,8 +611,12 @@ export class GBVMService extends GBService {
|
||||||
// Auto update Bearar authentication for the first token.
|
// Auto update Bearar authentication for the first token.
|
||||||
|
|
||||||
const expiresOn = new Date(global[tokenName + "_expiresOn"]);
|
const expiresOn = new Date(global[tokenName + "_expiresOn"]);
|
||||||
if (expiresOn.getTime() < new Date().getTime() || firstTime) {
|
const expiration = expiresOn.getTime() - (10 * 60 * 1000);
|
||||||
|
|
||||||
|
// Expires token 10min. before or if it the first time, load it.
|
||||||
|
|
||||||
|
if (expiration < new Date().getTime() || firstTime) {
|
||||||
|
console.log ('Expired. Refreshing token...');
|
||||||
const {token, expiresOn} = await sys.getCustomToken({pid, tokenName});
|
const {token, expiresOn} = await sys.getCustomToken({pid, tokenName});
|
||||||
|
|
||||||
global[tokenName] = token;
|
global[tokenName] = token;
|
||||||
|
|
Loading…
Add table
Reference in a new issue