update 日志

This commit is contained in:
2023-07-25 14:44:38 +08:00
parent 62cff16588
commit 5bd6963742

View File

@@ -5,6 +5,8 @@ import com.jsowell.common.constant.HttpStatus;
import com.jsowell.common.core.domain.AjaxResult;
import com.jsowell.common.util.ServletUtils;
import com.jsowell.common.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
@@ -23,11 +25,14 @@ import java.io.Serializable;
public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint, Serializable {
private static final long serialVersionUID = -8970718410437077606L;
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e)
throws IOException {
int code = HttpStatus.UNAUTHORIZED;
String msg = StringUtils.format("请求访问:{},认证失败,无法访问系统资源", request.getRequestURI());
logger.error("认证失败无法访问系统资源error", e);
ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(code, msg)));
}
}