针对本身token过期的问题处理
This commit is contained in:
@@ -100,16 +100,32 @@ public class LoginFilter implements Filter {
|
|||||||
}
|
}
|
||||||
String message = "";
|
String message = "";
|
||||||
String tokenKey="";
|
String tokenKey="";
|
||||||
|
|
||||||
|
JSONObject jsonObject1 = TokenUtil.parseParamFromToken(token);
|
||||||
|
if (jsonObject1.containsKey("status")){
|
||||||
|
String openId = request.getHeader("openId");
|
||||||
|
String userId = request.getHeader("id");
|
||||||
|
redisUtil.deleteByKey(RedisCst.ONLINE_USER.concat(openId));
|
||||||
|
redisUtil.deleteByKey(RedisCst.ONLINE_USER.concat(userId));
|
||||||
|
redisUtil.deleteByKey(RedisCst.ONLINE_APP_USER.concat(userId));
|
||||||
|
Result result = new Result(CodeEnum.TOKEN_EXPIRED);
|
||||||
|
String jsonString = JSONObject.toJSONString(result);
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(jsonString, JSONObject.class);
|
||||||
|
response.getWriter().print(jsonObject);
|
||||||
|
response.getWriter().flush();//流里边的缓存刷出
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(environment.equals("app")){
|
if(environment.equals("app")){
|
||||||
//获取当前登录人的用户id
|
//获取当前登录人的用户id
|
||||||
String userId = TokenUtil.parseParamFromToken(token).getString("userId");
|
String userId = jsonObject1.getString("userId");
|
||||||
tokenKey=RedisCst.ONLINE_APP_USER.concat(userId);
|
tokenKey=RedisCst.ONLINE_APP_USER.concat(userId);
|
||||||
//获取redis中的token
|
//获取redis中的token
|
||||||
}else if(environment.equals("wx")){
|
}else if(environment.equals("wx")){
|
||||||
//获取当前登录人的用户id
|
//获取当前登录人的用户id
|
||||||
String openId = TokenUtil.parseParamFromToken(token).getString("openId");
|
String openId = jsonObject1.getString("openId");
|
||||||
if(StringUtils.isBlank(openId)){
|
if(StringUtils.isBlank(openId)){
|
||||||
openId = TokenUtil.parseParamFromToken(token).getString("userId");
|
openId = jsonObject1.getString("userId");
|
||||||
}
|
}
|
||||||
tokenKey=RedisCst.ONLINE_USER.concat(openId);
|
tokenKey=RedisCst.ONLINE_USER.concat(openId);
|
||||||
}
|
}
|
||||||
@@ -131,15 +147,6 @@ public class LoginFilter implements Filter {
|
|||||||
response.getWriter().flush();//流里边的缓存刷出
|
response.getWriter().flush();//流里边的缓存刷出
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSONObject jsonObject1 = TokenUtil.parseParamFromToken(token);
|
|
||||||
if (jsonObject1.containsKey("status")){
|
|
||||||
Result result = new Result(CodeEnum.TOKEN_EXPIRED);
|
|
||||||
String jsonString = JSONObject.toJSONString(result);
|
|
||||||
JSONObject jsonObject = JSONObject.parseObject(jsonString, JSONObject.class);
|
|
||||||
response.getWriter().print(jsonObject);
|
|
||||||
response.getWriter().flush();//流里边的缓存刷出
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
checkRenewal(tokenKey);
|
checkRenewal(tokenKey);
|
||||||
chain.doFilter(req, resp);
|
chain.doFilter(req, resp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.rabbit;
|
package com.chaozhanggui.system.cashierservice.rabbit;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
|
||||||
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
|
||||||
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
|
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
|
||||||
import com.chaozhanggui.system.cashierservice.service.CartService;
|
|
||||||
import com.chaozhanggui.system.cashierservice.service.IntegralService;
|
import com.chaozhanggui.system.cashierservice.service.IntegralService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|||||||
Reference in New Issue
Block a user