Skip to content

Commit 38b975c

Browse files
AlexTugarevroboquat
authored andcommitted
[db] enable overriding of expiryDate on tokens
1 parent 845d718 commit 38b975c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

components/gitpod-db/src/typeorm/user-db-impl.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,15 @@ export class TypeORMUserDBImpl implements UserDB {
339339
if (tokenEntries.length === 0) {
340340
return undefined;
341341
}
342-
return tokenEntries.sort((a, b) => `${a.token.updateDate}`.localeCompare(`${b.token.updateDate}`)).reverse()[0]
343-
?.token;
342+
const latestTokenEntry = tokenEntries
343+
.sort((a, b) => `${a.token.updateDate}`.localeCompare(`${b.token.updateDate}`))
344+
.reverse()[0];
345+
if (latestTokenEntry) {
346+
if (latestTokenEntry.expiryDate !== latestTokenEntry.token.expiryDate) {
347+
log.info(`Overriding 'expiryDate' of token to get refreshed on demand.`, { identity });
348+
}
349+
return { ...latestTokenEntry.token, expiryDate: latestTokenEntry.expiryDate };
350+
}
344351
}
345352

346353
public async findTokensForIdentity(identity: Identity, includeDeleted?: boolean): Promise<TokenEntry[]> {

0 commit comments

Comments
 (0)