From c8a29326dec85f7fb7c5aaea4cef940c3f456834 Mon Sep 17 00:00:00 2001 From: stae1102 Date: Thu, 3 Oct 2024 16:14:15 +0900 Subject: [PATCH] fix: change jwt expiration --- src/auth/jwt/jwt.service.ts | 4 +++- src/categories/category.service.ts | 15 +++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/auth/jwt/jwt.service.ts b/src/auth/jwt/jwt.service.ts index e410a90..cfa0af5 100644 --- a/src/auth/jwt/jwt.service.ts +++ b/src/auth/jwt/jwt.service.ts @@ -7,7 +7,9 @@ export class customJwtService { constructor(private readonly jwtService: JwtService) {} sign(payload: Payload): string { - return this.jwtService.sign(payload); + return this.jwtService.sign(payload, { + expiresIn: payload.period, + }); } verify(token: string, options?: JwtVerifyOptions): Payload { diff --git a/src/categories/category.service.ts b/src/categories/category.service.ts index 4ffc064..ea1302a 100644 --- a/src/categories/category.service.ts +++ b/src/categories/category.service.ts @@ -212,18 +212,9 @@ export class CategoryService { queryRunnerManager: EntityManager, ): Promise { try { - const userInDb = - await this.userRepository.findOneWithContentsAndCategories(user.id); - - // Check if user exists - if (!userInDb) { - throw new NotFoundException('User not found.'); - } - - const category = userInDb.categories?.find( - (category) => category.id === categoryId, - ); - + const category = await this.categoryRepository.findOne({ + where: { id: categoryId }, + }); if (!category) { throw new NotFoundException('Category not found.'); }