2021与蓝度共同重构项目,服务端
liuhaonan
2022-07-22 74e253770f0c321ad47bb68e490e4a118f35fd35
sandu-common/src/main/java/com/sandu/common/security/token/JwtTokenProvider.java
@@ -69,7 +69,7 @@
                .compact();
        String key = String.format("%d_%d", loginUserInfo.getUserId(), loginUserInfo.getAdministratorType());
        redisService.set(key, token);
        redisService.set(key, token, 2592000);
        return token;
    }
@@ -88,22 +88,19 @@
            loginUserInfo.setStatus(AdminStatusStatus.NORMAL.getCode());
            String key = String.format("%d_%d", loginUserInfo.getUserId(), loginUserInfo.getAdministratorType());
            String redisToken = String.valueOf(redisService.get(key));
            if (redisToken == null || !token.equals(redisToken)) {
                throw new BusinessException("token无效");
            }
            //TODO  上线记得改回来
//            if (redisToken == null || !token.equals(redisToken)) {
//                throw new BusinessException("token无效");
//            }
            return loginUserInfo;
        } catch (io.jsonwebtoken.security.SecurityException | MalformedJwtException e) {
            log.info("Invalid JWT signature.");
//            e.printStackTrace();
        } catch (ExpiredJwtException e) {
            log.info("Expired JWT token.");
//            e.printStackTrace();
        } catch (UnsupportedJwtException | DecodingException e) {
            log.info("Unsupported JWT token.");
//            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            log.info("JWT token compact of handler are invalid.");
//            e.printStackTrace();
        }
        return null;