update token过期时间
This commit is contained in:
+1
-1
@@ -80,7 +80,7 @@ public class JwtUtil {
|
|||||||
*/
|
*/
|
||||||
public static String sign(String username, String secret) {
|
public static String sign(String username, String secret) {
|
||||||
// 24小时后过期
|
// 24小时后过期
|
||||||
Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME * 48);
|
Date date = new Date(System.currentTimeMillis() + EXPIRE_TIME);
|
||||||
Algorithm algorithm = Algorithm.HMAC256(secret);
|
Algorithm algorithm = Algorithm.HMAC256(secret);
|
||||||
// 附带username信息
|
// 附带username信息
|
||||||
return JWT.create().withClaim(USERNAME_FIELD, username).withExpiresAt(date).sign(algorithm);
|
return JWT.create().withClaim(USERNAME_FIELD, username).withExpiresAt(date).sign(algorithm);
|
||||||
|
|||||||
+1
-1
@@ -158,7 +158,7 @@ public class ShiroRealm extends AuthorizingRealm {
|
|||||||
String newAuthorization = JwtUtil.sign(userName, passWord);
|
String newAuthorization = JwtUtil.sign(userName, passWord);
|
||||||
// 设置超时时间
|
// 设置超时时间
|
||||||
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, newAuthorization);
|
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);
|
log.debug("——————————用户在线操作,更新token保证不掉线—————————jwtTokenRefresh——————— "+ token);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user