Skip to content

Commit

Permalink
Merge pull request #510 from Travel-in-nanaland/hotfix/#509-reissue
Browse files Browse the repository at this point in the history
[Feat] 에러 메시지 수정
  • Loading branch information
jyajoo authored Nov 14, 2024
2 parents 96e79ef + b98dd57 commit e813fbe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public JwtDto reissue(String bearerRefreshToken, String fcmToken) {
String refreshToken = jwtUtil.resolveToken(bearerRefreshToken);

if (!jwtUtil.verifyRefreshToken(refreshToken)) {
throw new UnauthorizedException(INVALID_TOKEN.getMessage());
throw new UnauthorizedException(INVALID_TOKEN.getMessage() + ": 리프레쉬토큰 유효하지 않음");
}

String memberId = jwtUtil.getMemberIdFromRefresh(refreshToken);
Expand All @@ -251,7 +251,7 @@ public JwtDto reissue(String bearerRefreshToken, String fcmToken) {
if (!refreshToken.equals(savedRefreshToken)) {
// RefreshToken 삭제 및 다시 로그인하도록 UNAUTHORIZED
jwtUtil.deleteRefreshToken(memberId);
throw new UnauthorizedException(INVALID_TOKEN.getMessage());
throw new UnauthorizedException(INVALID_TOKEN.getMessage() + ": 재사용된 토큰인 경우");
}

Member member = memberRepository.findById(Long.valueOf(memberId))
Expand Down Expand Up @@ -337,7 +337,7 @@ public void forceWithdrawal(String bearerAccessToken) {
String accessToken = jwtUtil.resolveToken(bearerAccessToken);

if (!jwtUtil.verifyAccessToken(accessToken)) {
throw new UnauthorizedException(INVALID_TOKEN.getMessage());
throw new UnauthorizedException(INVALID_TOKEN.getMessage() + ": 액세스토큰 유효하지 않음");
}

String memberId = jwtUtil.getMemberIdFromAccess(accessToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer m

// null이 아닌 경우, 로그아웃을 통해 이미 블랙리스트에 담긴 것을 의미
if (redisUtil.getValue(accessToken) != null) {
throw new UnauthorizedException(ErrorCode.INVALID_TOKEN.getMessage());
throw new UnauthorizedException(ErrorCode.INVALID_TOKEN.getMessage() + ": 로그아웃된 액세스토큰");
}

String memberId = jwtUtil.getMemberIdFromAccess(accessToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ void reissueFail_invalidToken() {
() -> memberLoginService.reissue("bearer RefreshToken", ""));

// then: ErrorCode 검증
assertThat(unauthorizedException.getMessage()).isEqualTo(ErrorCode.INVALID_TOKEN.getMessage());
assertThat(unauthorizedException.getMessage()).isEqualTo(ErrorCode.INVALID_TOKEN.getMessage() + ": 리프레쉬토큰 유효하지 않음");
}

@Test
Expand All @@ -499,7 +499,7 @@ void reissueFail_tokenDifferent() {
() -> memberLoginService.reissue("bearer RefreshToken", ""));

// then: ErrorCode 검증, RefreshToken 삭제 확인
assertThat(unauthorizedException.getMessage()).isEqualTo(ErrorCode.INVALID_TOKEN.getMessage());
assertThat(unauthorizedException.getMessage()).isEqualTo(ErrorCode.INVALID_TOKEN.getMessage() + ": 재사용된 토큰인 경우");
verify(jwtUtil).deleteRefreshToken(any(String.class));
}

Expand Down

0 comments on commit e813fbe

Please sign in to comment.