Skip to content

Commit a6b84c4

Browse files
fix: 토큰 에러 처리
1 parent 0d4101b commit a6b84c4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

apps/backend/src/auth/token/token.service.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Injectable } from '@nestjs/common';
22
import { JwtService } from '@nestjs/jwt';
33
import { Response } from 'express';
4+
import { InvalidTokenException } from '../../exception/invalid.exception';
45

56
const HOUR = 60 * 60;
67
const DAY = 24 * 60 * 60;
@@ -33,9 +34,13 @@ export class TokenService {
3334
}
3435

3536
verifyInviteToken(token: string): { workspaceId: string; role: string } {
36-
return this.jwtService.verify(token, {
37-
secret: process.env.JWT_SECRET,
38-
});
37+
try {
38+
return this.jwtService.verify(token, {
39+
secret: process.env.JWT_SECRET,
40+
});
41+
} catch (error) {
42+
throw new InvalidTokenException();
43+
}
3944
}
4045

4146
// 후에 DB 로직 (지금은 refreshToken이 DB로 관리 X)

0 commit comments

Comments
 (0)