| | |
| | | package com.ruoyi.gateway.filter; |
| | | |
| | | import com.ruoyi.common.core.exception.auth.NotLoginException; |
| | | import com.ruoyi.gateway.config.properties.AntiShakeProperties; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | public void verifyToken(ServerHttpRequest request) throws Exception{ |
| | | String token = getToken(request); |
| | | if (StringUtils.isEmpty(token)) { |
| | | throw new RuntimeException("令牌不能为空"); |
| | | throw new NotLoginException("令牌不能为空"); |
| | | } |
| | | Claims claims = JwtUtils.parseToken(token); |
| | | if (claims == null) { |
| | | throw new RuntimeException("令牌已过期或验证不正确!"); |
| | | throw new NotLoginException("令牌已过期或验证不正确!"); |
| | | } |
| | | String userid = JwtUtils.getUserId(claims); |
| | | if (StringUtils.isEmpty(userid)) { |
| | | throw new RuntimeException("令牌验证失败"); |
| | | throw new NotLoginException("令牌验证失败"); |
| | | } |
| | | } |
| | | |