update token过期时间

This commit is contained in:
liao
2023-05-05 16:11:31 +08:00
parent 461d3de42e
commit b80e8048df
2 changed files with 2 additions and 2 deletions
@@ -80,7 +80,7 @@ public class JwtUtil {
*/
public static String sign(String username, String secret) {
// 24小时后过期
Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME * 48);
Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME);
Algorithm algorithm = Algorithm.HMAC256(secret);
// 附带username信息
return JWT.create().withClaim(USERNAME_FIELD, username).withExpiresAt(date).sign(algorithm);
@@ -158,7 +158,7 @@ public class ShiroRealm extends AuthorizingRealm {
String newAuthorization = JwtUtil.sign(userName, passWord);
// 设置超时时间
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, newAuthorization);
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000);
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000 * 2);
log.debug("——————————用户在线操作,更新token保证不掉线—————————jwtTokenRefresh——————— "+ token);
}
return true;