diff --git a/cweb/src/main/java/com/cweb/config/AuthConfig.java b/cweb/src/main/java/com/cweb/config/AuthConfig.java index 4263028..fcd1aa2 100644 --- a/cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -63,10 +63,14 @@ public class AuthConfig implements WebMvcConfigurer { } String token = request.getHeader("Authorization"); if(StringUtils.isNotBlank(token) && userCenter.isLogin(token)){//如果未登录,将无法使用任何接口 + // 刷新登录缓存时间 + userCenter.refresh(request); return true; } else if(request instanceof StandardMultipartHttpServletRequest) { StandardMultipartHttpServletRequest re = (StandardMultipartHttpServletRequest)request; if(userCenter.isLogin(re.getRequest())){ + // 刷新登录缓存时间 + userCenter.refresh(request); return true; } else { log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL()); diff --git a/service/src/main/java/com/hfkj/common/security/UserCenter.java b/service/src/main/java/com/hfkj/common/security/UserCenter.java index 2bde068..1433c4e 100644 --- a/service/src/main/java/com/hfkj/common/security/UserCenter.java +++ b/service/src/main/java/com/hfkj/common/security/UserCenter.java @@ -21,7 +21,7 @@ public class UserCenter { @Autowired private RedisUtil redisUtil; - private final int EXPIRE = 3600 * 24 * 180; // 登录过期时间为180天 + private final int EXPIRE = 3600 * 24 * 90; // 登录过期时间为90天 /** * 保存登录信息 @@ -31,6 +31,17 @@ public class UserCenter { redisUtil.set(seObj.getToken(), seObj, EXPIRE); } + /** + * 刷新登录缓存时间 + * @throws Exception + */ + public void refresh(HttpServletRequest request) { + String token = request.getHeader("Authorization"); + if(StringUtils.isNotBlank(token)) { + redisUtil.expire(token, EXPIRE); + } + } + /** * 是否登录 * @param request