diff --git a/src/main/java/com/jeju/nanaland/domain/member/service/MemberLoginService.java b/src/main/java/com/jeju/nanaland/domain/member/service/MemberLoginService.java index 1ef30b41..f8e91ae0 100644 --- a/src/main/java/com/jeju/nanaland/domain/member/service/MemberLoginService.java +++ b/src/main/java/com/jeju/nanaland/domain/member/service/MemberLoginService.java @@ -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); @@ -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)) @@ -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); diff --git a/src/main/java/com/jeju/nanaland/global/auth/AuthMemberArgumentResolver.java b/src/main/java/com/jeju/nanaland/global/auth/AuthMemberArgumentResolver.java index 08ba114f..52d1351a 100644 --- a/src/main/java/com/jeju/nanaland/global/auth/AuthMemberArgumentResolver.java +++ b/src/main/java/com/jeju/nanaland/global/auth/AuthMemberArgumentResolver.java @@ -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); diff --git a/src/test/java/com/jeju/nanaland/domain/member/service/MemberLoginServiceTest.java b/src/test/java/com/jeju/nanaland/domain/member/service/MemberLoginServiceTest.java index fb1ae4cf..95875da7 100644 --- a/src/test/java/com/jeju/nanaland/domain/member/service/MemberLoginServiceTest.java +++ b/src/test/java/com/jeju/nanaland/domain/member/service/MemberLoginServiceTest.java @@ -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 @@ -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)); }