Browse Source

fix

release_toaliyun_real
xiaohanzi 6 years ago
parent
commit
ff2263e99b
1 changed files with 33 additions and 33 deletions
  1. +33
    -33
      mallinkCApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java

+ 33
- 33
mallinkCApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java View File

@@ -32,39 +32,39 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {
System.out.println(" requesturi......"+request.getRequestURL());
// AuthIgnore annotation;
// if(handler instanceof HandlerMethod) {
// annotation = ((HandlerMethod) handler).getMethodAnnotation(AuthIgnore.class);
// }else{
// return true;
// }
//
// //如果有@IgnoreAuth注解,则不验证token
// if(annotation != null){
// return true;
// }
//
// //从header中获取token
// String token = request.getHeader("token");
// //如果header中不存在token,则从参数中获取token
// if(StringUtils.isBlank(token)){
// token = request.getParameter("token");
// }
//
// //token为空
// if(StringUtils.isBlank(token)){
// throw new MallinkException(ErrorCode.NET_TOKEN_EMPTY);
// }
//
// // 查询token信息
// WxCUser wxCUser = userTokenService.getByToken(token);
// if(wxCUser == null || wxCUser.getExpireTime().getTime() < System.currentTimeMillis()){
// throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " token失效,请重新登录");
// }
//
// //设置userId到request里,后续根据userId,获取用户信息
// request.setAttribute(Constant.LOGIN_USER_KEY, wxCUser.getId());
// request.setAttribute(Constant.TENANT_ID, wxCUser.getTenantId());
AuthIgnore annotation;
if(handler instanceof HandlerMethod) {
annotation = ((HandlerMethod) handler).getMethodAnnotation(AuthIgnore.class);
}else{
return true;
}
//如果有@IgnoreAuth注解,则不验证token
if(annotation != null){
return true;
}
//从header中获取token
String token = request.getHeader("token");
//如果header中不存在token,则从参数中获取token
if(StringUtils.isBlank(token)){
token = request.getParameter("token");
}
//token为空
if(StringUtils.isBlank(token)){
throw new MallinkException(ErrorCode.NET_TOKEN_EMPTY);
}
// 查询token信息
WxCUser wxCUser = userTokenService.getByToken(token);
if(wxCUser == null || wxCUser.getExpireTime().getTime() < System.currentTimeMillis()){
throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " token失效,请重新登录");
}
//设置userId到request里,后续根据userId,获取用户信息
request.setAttribute(Constant.LOGIN_USER_KEY, wxCUser.getId());
request.setAttribute(Constant.TENANT_ID, wxCUser.getTenantId());

return true;
}


Loading…
Cancel
Save