fix: refresh token invalidate for logout

This commit is contained in:
mahyargdz
2025-03-11 12:33:00 +03:30
parent 4503721b90
commit 6eea07729b
9 changed files with 115 additions and 38 deletions
+3 -4
View File
@@ -125,9 +125,8 @@ export class TokensService {
}
/************************************************************ */
async invalidateRefreshToken(oldRefreshToken: string) {
const token = await this.refreshTokensRepository.findOne({ where: { token: oldRefreshToken }, relations: { user: true } });
if (token) await this.refreshTokensRepository.delete({ id: token.id });
async invalidateRefreshToken(userId: string) {
await this.refreshTokensRepository.delete({ user: { id: userId } });
this.logger.log(`Successfully deleted all refresh tokens for user ${userId}`);
}
}