Kirin hace 3 años
padre
commit
94cc60c106
Se han modificado 1 ficheros con 24 adiciones y 24 borrados
  1. 24 24
      app/http/middleware/AuthTokenMiddleware.php

+ 24 - 24
app/http/middleware/AuthTokenMiddleware.php

@@ -31,30 +31,30 @@ class AuthTokenMiddleware implements MiddlewareInterface
         try {
             $authInfo = UserRepository::parseToken($token);
             if (!is_null($authInfo)) {
-//                $sub_uid = $request->header('UID', 0);
-//                if ($authInfo['user']['main_uid'] == 0) {
-//                    $check = function ($item) use ($authInfo) {
-//                        return User::getUserInfo($item)['main_uid'] == $authInfo['user']['uid'] || User::getUserInfo($item)['uid'] == $authInfo['user']['uid'];
-//                    };
-//                } else {
-//                    $check = function ($item) use ($authInfo) {
-//                        return (User::getUserInfo($item)['main_uid'] == $authInfo['user']['main_uid']) || User::getUserInfo($item)['uid'] == $authInfo['user']['main_uid'];
-//                    };
-//                }
-//                if ($sub_uid) {
-//                    if ($check($sub_uid)) {
-//                        $authInfo['user'] = User::where('uid', $sub_uid)->find();
-//                    }
-//                    $main_user = User::getUserInfo($authInfo['user']['main_uid'] ?: $authInfo['user']['uid']);
-//                    if ($main_user['real_check'] == 1) {
-//                        $authInfo['user']['real_check'] = 1;
-//                        $authInfo['user']['real_name'] = $main_user['real_name'];
-//                        $authInfo['user']['card_id'] = $main_user['card_id'];
-//                    }
-//                }
-//                if (!$authInfo['user']['real_check'] && !in_array($request->action(), ['realNameCheck', 'logout', 'user', 'userinfo'])) {
-//                    throw new AuthException('请先进行实名认证');
-//                }
+                $sub_uid = $request->header('UID', 0);
+                if ($authInfo['user']['main_uid'] == 0) {
+                    $check = function ($item) use ($authInfo) {
+                        return User::getUserInfo($item)['main_uid'] == $authInfo['user']['uid'] || User::getUserInfo($item)['uid'] == $authInfo['user']['uid'];
+                    };
+                } else {
+                    $check = function ($item) use ($authInfo) {
+                        return (User::getUserInfo($item)['main_uid'] == $authInfo['user']['main_uid']) || User::getUserInfo($item)['uid'] == $authInfo['user']['main_uid'];
+                    };
+                }
+                if ($sub_uid) {
+                    if ($check($sub_uid)) {
+                        $authInfo['user'] = User::where('uid', $sub_uid)->find();
+                    }
+                    $main_user = User::getUserInfo($authInfo['user']['main_uid'] ?: $authInfo['user']['uid']);
+                    if ($main_user['real_check'] == 1) {
+                        $authInfo['user']['real_check'] = 1;
+                        $authInfo['user']['real_name'] = $main_user['real_name'];
+                        $authInfo['user']['card_id'] = $main_user['card_id'];
+                    }
+                }
+                if (!$authInfo['user']['real_check'] && !in_array($request->action(), ['realNameCheck', 'logout', 'user', 'userinfo'])) {
+                    throw new AuthException('请先进行实名认证');
+                }
                 if (!$authInfo['user']->is_promoter) {
                     $price = StoreOrder::where(['paid' => 1, 'refund_status' => 0, 'uid' => $authInfo['user']['uid']])->sum('pay_price');
                     $status = is_brokerage_statu($price);