From b98dd576e9f683dcd794ec04bc7adeb535a367ce Mon Sep 17 00:00:00 2001 From: jyajoo Date: Thu, 14 Nov 2024 23:42:55 +0900 Subject: [PATCH] =?UTF-8?q?[#509]=20feat:=20=EC=97=90=EB=9F=AC=20=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nanaland/domain/member/service/MemberLoginService.java | 6 +++--- .../nanaland/global/auth/AuthMemberArgumentResolver.java | 2 +- .../domain/member/service/MemberLoginServiceTest.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) 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)); }