Skip to content

Commit

Permalink
Merge pull request #352 from Quickchive/fix/change-jwt-expire
Browse files Browse the repository at this point in the history
fix: change jwt expiration
  • Loading branch information
stae1102 authored Oct 3, 2024
2 parents e0da7f4 + c8a2932 commit 5626724
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/auth/jwt/jwt.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 3 additions & 12 deletions src/categories/category.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,9 @@ export class CategoryService {
queryRunnerManager: EntityManager,
): Promise<DeleteCategoryOutput> {
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.');
}
Expand Down

0 comments on commit 5626724

Please sign in to comment.