diff --git a/op-auth/src/main/java/com/op/auth/service/SysLoginService.java b/op-auth/src/main/java/com/op/auth/service/SysLoginService.java index c5868ad13..f3c9fc71e 100644 --- a/op-auth/src/main/java/com/op/auth/service/SysLoginService.java +++ b/op-auth/src/main/java/com/op/auth/service/SysLoginService.java @@ -97,7 +97,7 @@ public class SysLoginService { passwordService.validate(user, password); // 缓存用户工厂数据源 redisService.setCacheObject(CacheConstants.USER_POOL_NAME_CURRENT + username, userInfo.getPoolName(), - CacheConstants.REFRESH_TIME, TimeUnit.MINUTES); + CacheConstants.EXPIRATION, TimeUnit.MINUTES); recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功"); return userInfo; } diff --git a/op-common/op-common-security/src/main/java/com/op/common/security/service/TokenService.java b/op-common/op-common-security/src/main/java/com/op/common/security/service/TokenService.java index 2154b6d51..748278cb9 100644 --- a/op-common/op-common-security/src/main/java/com/op/common/security/service/TokenService.java +++ b/op-common/op-common-security/src/main/java/com/op/common/security/service/TokenService.java @@ -3,9 +3,12 @@ package com.op.common.security.service; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; + import javax.servlet.http.HttpServletRequest; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; + import com.op.common.core.constant.CacheConstants; import com.op.common.core.constant.SecurityConstants; import com.op.common.core.utils.JwtUtils; @@ -31,7 +34,7 @@ public class TokenService { protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND; - private final static long expireTime = CacheConstants.EXPIRATION; +// private final static long expireTime = CacheConstants.EXPIRATION; private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY; @@ -59,7 +62,7 @@ public class TokenService { // 接口返回信息 Map rspMap = new HashMap(); rspMap.put("access_token", JwtUtils.createToken(claimsMap)); - rspMap.put("expires_in", expireTime); + rspMap.put("expires_in", CacheConstants.EXPIRATION); return rspMap; } @@ -140,15 +143,16 @@ public class TokenService { */ public void refreshToken(LoginUser loginUser) { loginUser.setLoginTime(System.currentTimeMillis()); - loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE); + loginUser.setExpireTime(loginUser.getLoginTime() + CacheConstants.EXPIRATION * MILLIS_MINUTE); // 根据uuid将loginUser缓存 String userKey = getTokenKey(loginUser.getToken()); - redisService.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES); + redisService.setCacheObject(userKey, loginUser, CacheConstants.EXPIRATION, TimeUnit.MINUTES); String username = loginUser.getUsername(); // 重置过期时间 String pool = redisService.getCacheObject(CacheConstants.USER_POOL_NAME_CURRENT + username); - redisService.setCacheObject(CacheConstants.USER_POOL_NAME_CURRENT + username, pool, expireTime, TimeUnit.MINUTES); + redisService.setCacheObject(CacheConstants.USER_POOL_NAME_CURRENT + username, pool, CacheConstants.EXPIRATION, + TimeUnit.MINUTES); } private String getTokenKey(String token) { diff --git a/op-modules/op-system/src/main/java/com/op/system/controller/SysUserController.java b/op-modules/op-system/src/main/java/com/op/system/controller/SysUserController.java index 28a79966e..a1cbdc10a 100644 --- a/op-modules/op-system/src/main/java/com/op/system/controller/SysUserController.java +++ b/op-modules/op-system/src/main/java/com/op/system/controller/SysUserController.java @@ -368,7 +368,7 @@ public class SysUserController extends BaseController { String username = SecurityUtils.getUsername(); // 缓存用户工厂数据源 redisService.setCacheObject(CacheConstants.USER_POOL_NAME_CURRENT + username, user.getPoolName(), - CacheConstants.REFRESH_TIME, TimeUnit.MINUTES); + CacheConstants.EXPIRATION, TimeUnit.MINUTES); return success(); }