cjl
2023-09-28 e94e5dbbfc544c558a09fb388e7f4d4341fe8ec4
screen-common/src/main/java/com/moral/util/TokenUtils.java
@@ -85,7 +85,7 @@
     * @Author: 陈凯裕
     * @Date: 2021/3/10
     */
    public static void checkToken(String token) {
    public static boolean checkToken(String token) {
        try {
            String[] tokenArray = TokenEncryptUtils.decoded(token).split("/");
            //校验token是否合法
@@ -99,9 +99,9 @@
                        ResponseCodeEnum.TOKEN_INVALID.getMsg());
            }
        } catch (Exception e) {
            throw new TokenException(ResponseCodeEnum.TOKEN_INVALID.getCode(),
                    ResponseCodeEnum.TOKEN_INVALID.getMsg());
            return false;
        }
        return true;
    }
@@ -120,6 +120,11 @@
        return userInfo;
    }
    public static Object getUserInfo() {
        String token = getCurrentToken();
        return getUserInfoByToken(token);
    }
    /**
     * @Description: 销毁token
     * @Param: [uid, token]
@@ -128,6 +133,8 @@
     * @Date: 2021/3/11
     */
    public static void destoryToken(String uid, String token) {
        if(ObjectUtils.isEmpty(uid)||ObjectUtils.isEmpty(token))
            return;
        redisTemplate.delete(token);
        redisTemplate.opsForHash().delete("user_token", uid);
    }
@@ -144,6 +151,7 @@
        destoryToken(getUidByToken(token), token);
    }
    /**
     * @Description: 销毁当前连接的token
     * @Param: []