From a49390cb88cfcfb63d4c66bd86a1e6b7320c48b3 Mon Sep 17 00:00:00 2001 From: JunRain Date: Wed, 5 Jun 2024 20:48:06 +0900 Subject: [PATCH] =?UTF-8?q?[hotfix]=20sendError=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../filter/JwtAuthenticationProcessingFilter.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/backend/memetory/src/main/java/com/example/memetory/global/security/jwt/filter/JwtAuthenticationProcessingFilter.java b/backend/memetory/src/main/java/com/example/memetory/global/security/jwt/filter/JwtAuthenticationProcessingFilter.java index 05ca701..b7fbd95 100644 --- a/backend/memetory/src/main/java/com/example/memetory/global/security/jwt/filter/JwtAuthenticationProcessingFilter.java +++ b/backend/memetory/src/main/java/com/example/memetory/global/security/jwt/filter/JwtAuthenticationProcessingFilter.java @@ -51,7 +51,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse String refreshToken = jwtService.extractRefreshToken(request); checkRefreshTokenAndReIssueAccessToken(response, refreshToken); - sendError(response, HttpServletResponse.SC_UNAUTHORIZED); + response.setStatus(SC_UNAUTHORIZED); } catch (NotFoundTokenException e) { checkAccessTokenAndAuthentication(request, response, filterChain); } @@ -70,9 +70,8 @@ private void checkAccessTokenAndAuthentication(HttpServletRequest request, HttpS String email = jwtService.getEmail(request); memberRepository.findByEmail(email).ifPresent(this::saveAuthentication); } catch (Exception e) { - sendError(response, SC_FORBIDDEN); - } - finally { + response.setStatus(SC_FORBIDDEN); + } finally { filterChain.doFilter(request, response); } } @@ -91,12 +90,4 @@ private void saveAuthentication(Member myMember) { SecurityContextHolder.getContext().setAuthentication(authentication); } - - private void sendError(HttpServletResponse response, int errorCode) { - try { - response.sendError(errorCode); - } catch (IOException e) { - throw new RuntimeException(e); - } - } }