Browse Source

jwt token获取优化,弃用原先的 httpUtil::getHeader()方法

shizhongqi 7 months ago
parent
commit
c2adf9c87d

+ 3 - 3
app-ghs/controllers/BaseController.php

@@ -96,9 +96,9 @@ class BaseController extends PublicController
             if (empty($shopAdmin)) {
                 util::logout('没有找到员工');
             }
-            if (isset($shopAdmin->delStatus) && $shopAdmin->delStatus == 1) {
-                util::fail('您不是本店员工哦');
-            }
+            // if (isset($shopAdmin->delStatus) && $shopAdmin->delStatus == 1) { //第95行查询时已限定 'delStatus' => 0, $shopAdmin->delStatus == 1 永远不会成立
+            //     util::fail('您不是本店员工哦');
+            // }
             if (isset($shopAdmin->status) && $shopAdmin->status == 0) {
                 util::fail('您已被平台禁止登录');
             }

+ 4 - 2
common/components/httpUtil.php

@@ -88,8 +88,10 @@ class httpUtil
 
     public static function getToken()
     {
-        $header = self::getHeader();
-        $token = isset($header['token']) ? $header['token'] : '';
+        $token = $_SERVER['HTTP_TOKEN'] ?? '';
+        if (empty($token)) {
+            $token = Yii::$app->request->get('token', '');
+        }
         return $token;
     }
 

+ 1 - 2
common/components/jwt.php

@@ -78,8 +78,7 @@ class jwt
 	//判断有没登陆并返回id ssh 2019.11.22
 	public static function getLoginId()
 	{
-		$header = httpUtil::getHeader();
-		$token = isset($header['token']) && !empty($header['token']) ? $header['token'] : Yii::$app->request->get('token', '');
+		$token = httpUtil::getToken();
 		if (empty($token)) {
 			return 0;
 		}