From a95ecaf7c67dc3fd872d1c9fa176b49294365ff1 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Thu, 04 Mar 2021 14:56:06 +0800 Subject: [PATCH] 20210304 最大持仓数设置0时,显示为空 --- src/main/java/com/xcong/excoin/configurations/security/CustomAuthenticationEntryPoint.java | 20 ++++++++++++++++---- 1 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/xcong/excoin/configurations/security/CustomAuthenticationEntryPoint.java b/src/main/java/com/xcong/excoin/configurations/security/CustomAuthenticationEntryPoint.java index a28ffb8..98b1cdd 100644 --- a/src/main/java/com/xcong/excoin/configurations/security/CustomAuthenticationEntryPoint.java +++ b/src/main/java/com/xcong/excoin/configurations/security/CustomAuthenticationEntryPoint.java @@ -1,11 +1,13 @@ package com.xcong.excoin.configurations.security; import com.fasterxml.jackson.databind.ObjectMapper; +import com.xcong.excoin.common.contants.AppContants; import com.xcong.excoin.common.response.Result; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -18,9 +20,19 @@ @Override public void commence(HttpServletRequest httpServletRequest, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException { - Result result = Result.loginFail("fail"); - response.setCharacterEncoding("UTF-8"); - response.setContentType("application/json; charset=utf-8"); - response.getWriter().write(new ObjectMapper().writeValueAsString(result)); + String timeOut = response.getHeader("TimeOut"); + if (AppContants.TIME_OUT.equals(timeOut)) { + Result result = Result.timeOut("Time Out"); + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/json; charset=utf-8"); + response.getWriter().write(new ObjectMapper().writeValueAsString(result)); + response.setStatus(HttpServletResponse.SC_REQUEST_TIMEOUT); + } else { + Result result = Result.loginFail("Unauthorized"); + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/json; charset=utf-8"); + response.getWriter().write(new ObjectMapper().writeValueAsString(result)); + response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + } } } -- Gitblit v1.9.1