Skip to content

Commit

Permalink
Avoid token renewal 30mins before time of expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTugarev authored and roboquat committed Jun 24, 2022
1 parent 1bb3ff9 commit 9a9c01e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions components/server/src/user/token-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export class TokenService implements TokenProvider {
`No token found for user ${identity.authProviderId}/${identity.authId}/${identity.authName}!`,
);
}
const refreshTime = new Date();
refreshTime.setTime(refreshTime.getTime() + 30 * 60 * 1000);
if (token.expiryDate && token.expiryDate < refreshTime.toISOString()) {
const aboutToExpireTime = new Date();
aboutToExpireTime.setTime(aboutToExpireTime.getTime() + 5 * 60 * 1000);
if (token.expiryDate && token.expiryDate < aboutToExpireTime.toISOString()) {
const { authProvider } = this.hostContextProvider.get(host)!;
if (authProvider.refreshToken) {
await authProvider.refreshToken(user);
Expand Down

0 comments on commit 9a9c01e

Please sign in to comment.