From c4091d14a34966c9163438b7707e53989160453f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9A=A9=EC=88=98?= Date: Thu, 19 Sep 2024 17:57:44 +0900 Subject: [PATCH] =?UTF-8?q?Refactor:=20Error=20=EC=9D=91=EB=8B=B5=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/handler/CustomAuthenticationDeniedHandler.java | 4 ---- .../auth/handler/CustomAuthenticationEntryPoint.java | 7 ------- .../worlabel/global/filter/JwtAuthenticationFilter.java | 1 - 3 files changed, 12 deletions(-) diff --git a/backend/src/main/java/com/worlabel/domain/auth/handler/CustomAuthenticationDeniedHandler.java b/backend/src/main/java/com/worlabel/domain/auth/handler/CustomAuthenticationDeniedHandler.java index c07673c..1cecf0e 100644 --- a/backend/src/main/java/com/worlabel/domain/auth/handler/CustomAuthenticationDeniedHandler.java +++ b/backend/src/main/java/com/worlabel/domain/auth/handler/CustomAuthenticationDeniedHandler.java @@ -21,9 +21,5 @@ public class CustomAuthenticationDeniedHandler implements AccessDeniedHandler { public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException, ServletException { log.debug("오류 : {}", request.getAttribute("error-message")); response.setStatus(HttpServletResponse.SC_FORBIDDEN); - CustomException exception = new CustomException(ErrorCode.ACCESS_DENIED); - ErrorResponse errorResponse = new ErrorResponse(exception, request.getAttribute("error-message").toString()); - response.setContentType("application/json;charset=utf-8"); - response.getWriter().write(errorResponse.toJson()); } } diff --git a/backend/src/main/java/com/worlabel/domain/auth/handler/CustomAuthenticationEntryPoint.java b/backend/src/main/java/com/worlabel/domain/auth/handler/CustomAuthenticationEntryPoint.java index 4c21a6a..e5391ba 100644 --- a/backend/src/main/java/com/worlabel/domain/auth/handler/CustomAuthenticationEntryPoint.java +++ b/backend/src/main/java/com/worlabel/domain/auth/handler/CustomAuthenticationEntryPoint.java @@ -21,12 +21,5 @@ public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { log.debug("인증 실패 오류 : {} ", request.getAttribute("error-message")); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); - CustomException exception = new CustomException(ErrorCode.INVALID_TOKEN); - if (request.getAttribute("error-message") == null) { - request.setAttribute("error-message", exception.getMessage()); - } - ErrorResponse errorResponse = new ErrorResponse(exception, request.getAttribute("error-message").toString()); - response.setContentType("application/json;charset=UTF-8"); - response.getWriter().write(errorResponse.toJson()); } } diff --git a/backend/src/main/java/com/worlabel/global/filter/JwtAuthenticationFilter.java b/backend/src/main/java/com/worlabel/global/filter/JwtAuthenticationFilter.java index 328c5d3..39b4683 100644 --- a/backend/src/main/java/com/worlabel/global/filter/JwtAuthenticationFilter.java +++ b/backend/src/main/java/com/worlabel/global/filter/JwtAuthenticationFilter.java @@ -49,7 +49,6 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter { throw new JwtException("유효한 JWT 토큰이 없습니다."); } } catch (Exception e) { - log.debug("message: {}", e.getMessage()); request.setAttribute("error-message", e.getMessage()); } filterChain.doFilter(request, response);