RuoYi
2025-03-01 d91d0f51bb5eff7bed395dcfb388996fefbbd3c3
src/main/java/com/ruoyi/framework/security/service/TokenService.java
@@ -49,7 +49,7 @@
    protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND;
    private static final Long MILLIS_MINUTE_TEN = 20 * 60 * 1000L;
    private static final Long MILLIS_MINUTE_TWENTY = 20 * 60 * 1000L;
    @Autowired
    private RedisCache redisCache;
@@ -120,20 +120,21 @@
        Map<String, Object> claims = new HashMap<>();
        claims.put(Constants.LOGIN_USER_KEY, token);
        claims.put(Constants.JWT_USERNAME, loginUser.getUsername());
        return createToken(claims);
    }
    /**
     * 验证令牌有效期,相差不足20分钟,自动刷新缓存
     * 
     * @param token 令牌
     * @param loginUser 登录信息
     * @return 令牌
     */
    public void verifyToken(LoginUser loginUser)
    {
        long expireTime = loginUser.getExpireTime();
        long currentTime = System.currentTimeMillis();
        if (expireTime - currentTime <= MILLIS_MINUTE_TEN)
        if (expireTime - currentTime <= MILLIS_MINUTE_TWENTY)
        {
            refreshToken(loginUser);
        }
@@ -152,7 +153,7 @@
        String userKey = getTokenKey(loginUser.getToken());
        redisCache.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES);
    }
    /**
     * 设置用户代理信息
     * 
@@ -167,7 +168,7 @@
        loginUser.setBrowser(userAgent.getBrowser().getName());
        loginUser.setOs(userAgent.getOperatingSystem().getName());
    }
    /**
     * 从数据声明生成令牌
     *