Skip to content

Commit

Permalink
[db] enable overriding of expiryDate on tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTugarev authored and roboquat committed May 18, 2022
1 parent 845d718 commit 38b975c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions components/gitpod-db/src/typeorm/user-db-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,15 @@ export class TypeORMUserDBImpl implements UserDB {
if (tokenEntries.length === 0) {
return undefined;
}
return tokenEntries.sort((a, b) => `${a.token.updateDate}`.localeCompare(`${b.token.updateDate}`)).reverse()[0]
?.token;
const latestTokenEntry = tokenEntries
.sort((a, b) => `${a.token.updateDate}`.localeCompare(`${b.token.updateDate}`))
.reverse()[0];
if (latestTokenEntry) {
if (latestTokenEntry.expiryDate !== latestTokenEntry.token.expiryDate) {
log.info(`Overriding 'expiryDate' of token to get refreshed on demand.`, { identity });
}
return { ...latestTokenEntry.token, expiryDate: latestTokenEntry.expiryDate };
}
}

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

0 comments on commit 38b975c

Please sign in to comment.