Commit 4782adaa authored by wzp's avatar wzp

修改bug

parent d5a6ed7d
...@@ -46,15 +46,20 @@ public class JwtFilter extends BasicHttpAuthenticationFilter { ...@@ -46,15 +46,20 @@ public class JwtFilter extends BasicHttpAuthenticationFilter {
@Override @Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) { protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
LOGGER.info("isAccessAllowed"); LOGGER.info("isAccessAllowed");
if (isLoginAttempt(request, response)) { // if (isLoginAttempt(request, response)) {
//if (!isLoginAttempt(request, response) || !executeLogin(request,response)) { //if (!isLoginAttempt(request, response) || !executeLogin(request,response)) {
try { try {
executeLogin(request, response); executeLogin(request, response);
} catch (UnauthorizedException | AuthenticationException e) { return true;
throw new AuthenticationException("Token失效,请重新登录", e); } catch (UnauthorizedException e) {
// response403(request,response);
return false;
} catch (AuthenticationException ae) {
// response401(request, response);
return false;
} }
} // }
return true; // return true;
} }
/** /**
...@@ -97,8 +102,8 @@ public class JwtFilter extends BasicHttpAuthenticationFilter { ...@@ -97,8 +102,8 @@ public class JwtFilter extends BasicHttpAuthenticationFilter {
HttpServletResponse response = (HttpServletResponse) resp; HttpServletResponse response = (HttpServletResponse) resp;
response.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8");
response.setContentType("application/json;charset=utf-8"); response.setContentType("application/json;charset=utf-8");
response.setStatus(401); response.setStatus(1109);
response.getWriter().write("{\"status\":401,\"message\":\"未登录!\"}"); response.getWriter().write("{\"resultCode\":1109,\"message\":\"账号认证失败!\"}");
} catch (IOException e) { } catch (IOException e) {
LOGGER.error(e.getMessage()); LOGGER.error(e.getMessage());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment