fixup! chore(platform): OAuth Flow (#12798)

This commit is contained in:
Morgan Vernay 2023-12-20 19:13:56 +01:00
parent 0830f3304e
commit 9ef24864b8
2 changed files with 6 additions and 5 deletions

View File

@ -27,13 +27,13 @@ export class OAuthFlowService {
return true;
}
const token = await this.tokensRepository.getAccessTokenBySecret(secret);
const tokenExpiresAt = await this.tokensRepository.getAccessTokenExpiryDate(secret);
if (!token) {
if (!tokenExpiresAt) {
throw new UnauthorizedException();
}
if (new Date() > token?.expiresAt) {
if (new Date() > tokenExpiresAt) {
throw new BadRequestException("Token is expired");
}

View File

@ -59,8 +59,8 @@ export class TokensRepository {
};
}
async getAccessTokenBySecret(secret: string) {
return this.dbRead.prisma.accessToken.findFirst({
async getAccessTokenExpiryDate(secret: string) {
const accessToken = await this.dbRead.prisma.accessToken.findFirst({
where: {
secret,
},
@ -68,6 +68,7 @@ export class TokensRepository {
expiresAt: true,
},
});
return accessToken?.expiresAt;
}
async refreshOAuthTokens(clientId: string, refreshTokenSecret: string, tokenUserId: number) {