Bläddra i källkod

使用getToken没获取到token返回未登录

lyhzzz 2 år sedan
förälder
incheckning
cff646000f
1 ändrade filer med 5 tillägg och 0 borttagningar
  1. 5 0
      src/main/java/com/fdkankan/ucenter/common/BaseController.java

+ 5 - 0
src/main/java/com/fdkankan/ucenter/common/BaseController.java

@@ -1,7 +1,9 @@
 package com.fdkankan.ucenter.common;
 
+import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.util.DateEditor;
 import com.fdkankan.ucenter.common.constants.NacosProperty;
+import com.fdkankan.ucenter.constant.LoginConstant;
 import com.fdkankan.ucenter.util.DateUserUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -85,6 +87,9 @@ public class BaseController {
     }
 
     protected String getToken(){
+        if(org.apache.commons.lang3.StringUtils.isNotBlank(request.getHeader("token")) ){
+            throw new BusinessException(LoginConstant.FAILURE_CODE_3004, LoginConstant.FAILURE_MSG_3004);
+        }
         return request.getHeader("token");
     }
     protected String getSign(){