From 6ec0ced095edd975841608055f2d72103fa74e74 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Mon, 26 Jun 2023 17:23:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AEsession=E8=BF=87=E6=9C=9Fhttp?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/security/auth/handler/DefaultExpiredSessionStrategy.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/handler/DefaultExpiredSessionStrategy.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/handler/DefaultExpiredSessionStrategy.java index 5024ae8..ecbb68a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/handler/DefaultExpiredSessionStrategy.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/handler/DefaultExpiredSessionStrategy.java @@ -6,11 +6,11 @@ import com.ningdatech.pmapi.user.security.auth.errorcode.AuthErrorCodeEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.security.web.session.SessionInformationExpiredEvent; import org.springframework.security.web.session.SessionInformationExpiredStrategy; import org.springframework.stereotype.Component; -import javax.servlet.ServletException; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -29,11 +29,9 @@ public class DefaultExpiredSessionStrategy implements SessionInformationExpiredS @Override public void onExpiredSessionDetected(SessionInformationExpiredEvent sessionInformationExpiredEvent) - throws IOException, ServletException { - if (LOG.isInfoEnabled()) { - LOG.info("session is expired"); - } + throws IOException { HttpServletResponse response = sessionInformationExpiredEvent.getResponse(); + response.setStatus(HttpStatus.UNAUTHORIZED.value()); response.setContentType("application/json;charset=UTF-8"); response.getWriter().write(objectMapper.writeValueAsString( ApiResponse.of(AuthErrorCodeEnum.SESSION_EXPIRED.getCode(), AuthErrorCodeEnum.SESSION_EXPIRED.getMsg(), null)));