fixup! chore(platform): OAuth Flow (#12798)
This commit is contained in:
parent
0830f3304e
commit
9ef24864b8
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user