mirror of https://github.com/elunez/eladmin
parent
2a879115bc
commit
3b6b514ada
|
@ -103,14 +103,15 @@ public class TokenProvider implements InitializingBean {
|
|||
*/
|
||||
public void checkRenewal(String token) {
|
||||
// 判断是否续期token,计算token的过期时间
|
||||
long time = redisUtils.getExpire(properties.getOnlineKey() + token) * 1000;
|
||||
String loginKey = loginKey(token);
|
||||
long time = redisUtils.getExpire(loginKey) * 1000;
|
||||
Date expireDate = DateUtil.offset(new Date(), DateField.MILLISECOND, (int) time);
|
||||
// 判断当前时间与过期时间的时间差
|
||||
long differ = expireDate.getTime() - System.currentTimeMillis();
|
||||
// 如果在续期检查的范围内,则续期
|
||||
if (differ <= properties.getDetect()) {
|
||||
long renew = time + properties.getRenew();
|
||||
redisUtils.expire(properties.getOnlineKey() + token, renew, TimeUnit.MILLISECONDS);
|
||||
redisUtils.expire(loginKey, renew, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue