mirror of
https://gitee.com/ZhongBangKeJi/crmeb_java.git
synced 2026-05-04 07:41:24 +08:00
紧急修复了一些bug
This commit is contained in:
@@ -2,8 +2,9 @@ package com.common;
|
||||
|
||||
import com.constants.Constants;
|
||||
import com.utils.RedisUtil;
|
||||
import com.utils.RequestUtil;
|
||||
import com.utils.ThreadLocalUtil;
|
||||
import com.zbkj.crmeb.authorization.model.TokenModel;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -23,7 +24,7 @@ public class CheckFrontToken {
|
||||
@Autowired
|
||||
protected RedisUtil redisUtil;
|
||||
|
||||
public Boolean check(String token){
|
||||
public Boolean check(String token, HttpServletRequest request){
|
||||
|
||||
try {
|
||||
boolean exists = redisUtil.exists(Constants.USER_TOKEN_REDIS_KEY_PREFIX + token);
|
||||
@@ -35,13 +36,29 @@ public class CheckFrontToken {
|
||||
ThreadLocalUtil.set(hashedMap);
|
||||
|
||||
redisUtil.set(Constants.USER_TOKEN_REDIS_KEY_PREFIX +token, value, Constants.TOKEN_EXPRESS_MINUTES, TimeUnit.MINUTES);
|
||||
}else{
|
||||
//判断路由,部分路由不管用户是否登录/token过期都可以访问
|
||||
exists = checkRouter(RequestUtil.getUri(request));
|
||||
}
|
||||
|
||||
|
||||
return exists;
|
||||
}catch (Exception e){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//路由在此处,则返回true,无论用户是否登录都可以访问
|
||||
public boolean checkRouter(String uri) {
|
||||
String[] routerList = {
|
||||
"api/front/product/detail",
|
||||
"api/front/coupons",
|
||||
"api/front/index"
|
||||
};
|
||||
|
||||
return ArrayUtils.contains(routerList, uri);
|
||||
}
|
||||
|
||||
public String getTokenFormRequest(HttpServletRequest request){
|
||||
return request.getHeader(Constants.HEADER_AUTHORIZATION_KEY);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user