puzhibing
2025-01-13 acccff9860b271d55c55dc87486f7c20b9896e6c
ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java
@@ -1,5 +1,6 @@
package com.ruoyi.gateway.filter;
import com.ruoyi.common.core.exception.auth.NotPermissionException;
import com.ruoyi.gateway.config.properties.AntiShakeProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -131,7 +132,7 @@
   /**
    * 防抖处理
    */
   public void antiShake(ServerHttpRequest request) throws Exception{
   public void antiShake(ServerHttpRequest request) {
      HttpMethod method = request.getMethod();
      if(HttpMethod.OPTIONS == method || !antiShakeProperties.getEnable()){
         return;
@@ -174,20 +175,19 @@
   /**
    * 验证token
    * @param request
    * @throws Exception
    */
   public void verifyToken(ServerHttpRequest request) throws Exception{
   public void verifyToken(ServerHttpRequest request) {
      String token = getToken(request);
      if (StringUtils.isEmpty(token)) {
         throw new RuntimeException("令牌不能为空");
         throw new NotPermissionException("令牌不能为空");
      }
      Claims claims = JwtUtils.parseToken(token);
      if (claims == null) {
         throw new RuntimeException("令牌已过期或验证不正确!");
         throw new NotPermissionException("令牌已过期或验证不正确!");
      }
      String userid = JwtUtils.getUserId(claims);
      if (StringUtils.isEmpty(userid)) {
         throw new RuntimeException("令牌验证失败");
         throw new NotPermissionException("令牌验证失败");
      }
   }