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.'); }