Skip to content

Commit 9624bf7

Browse files
Merge pull request #4985 from topcoder-platform/issue-4953-hotfix
Re added refresh token to community-app
2 parents e84f2cf + db61f47 commit 9624bf7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/client/index.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ function authenticate(store) {
107107
store.dispatch(actions.direct.dropAll());
108108
store.dispatch(actions.groups.dropGroups());
109109
}
110+
111+
/* Automatic refreshment of auth tokens. */
112+
let time = Number.MAX_VALUE;
113+
if (tctV2) time = decodeToken(tctV2).exp;
114+
if (userV3) time = Math.min(time, userV3.exp);
115+
if (time < Number.MAX_VALUE) {
116+
time = Math.max(1000, (time * 1000) - Date.now());
117+
logger.log('Reauth scheduled in', time / 1000, 'seconds');
118+
setTimeout(() => authenticate(store), time + 1000);
119+
}
110120
});
111121
}
112122

0 commit comments

Comments
 (0)