kaiyu
2021-03-10 9e1e73064f54ac5c0ecebdbccfeff3e4267437e8
更新TokenUtils BUG
2 files modified
15 ■■■■■ changed files
screen-common/src/main/java/com/moral/util/AESUtils.java 6 ●●●●● patch | view | raw | blame | history
screen-common/src/main/java/com/moral/util/TokenUtils.java 9 ●●●●● patch | view | raw | blame | history
screen-common/src/main/java/com/moral/util/AESUtils.java
@@ -69,11 +69,5 @@
        return null;
    }
    public static void main(String[] args) {
        System.out.println(encrypt("123456").length());
        System.out.println(encrypt("chenkaiyu111").length());
        System.out.println(encrypt("ASDKJLFHDLSKJ").length());
        System.out.println(encrypt("chenkaiiiiiiiiiiiii").length());
    }
}
screen-common/src/main/java/com/moral/util/TokenUtils.java
@@ -50,9 +50,18 @@
        Map<String, Object> result = new HashMap<>();
        //生成加密token
        try {
            //生成token
            String token = TokenEncryptUtils.encoded(uid + "/" + System.currentTimeMillis() / 1000);
            //查询旧的token
            String oldToken = (String) redisTemplate.opsForHash().get("user_token", uid);
            if(oldToken!=null)
                redisTemplate.delete(oldToken);
            //新token写入到value中
            redisTemplate.opsForValue().set(token, userInfo);
            redisTemplate.expire(token, validity_time, TimeUnit.SECONDS);
            //新token写入到Hash中
            redisTemplate.opsForHash().put("user_token",uid,token);
            result.put("code", valid);
            result.put("token",token);
        }catch (Exception e){