Browse Source

app-ghs 也要处理 -- fix bug: 解决不是本帐号的门店也能被切换成功,造成数据与帐号权限出错

shizhongqi 1 year ago
parent
commit
d9462b3524
2 changed files with 7 additions and 1 deletions
  1. 0 1
      app-ghs/controllers/ShopController.php
  2. 7 0
      biz-ghs/admin/classes/AdminClass.php

+ 0 - 1
app-ghs/controllers/ShopController.php

@@ -336,7 +336,6 @@ class ShopController extends BaseController
     //切换门店 lqh 2021.1.31
     public function actionToggleShop()
     {
-
         $mainId = $this->mainId;
         $adminId = $this->adminId;
         if (getenv('YII_ENV') == 'production') {

+ 7 - 0
biz-ghs/admin/classes/AdminClass.php

@@ -410,6 +410,13 @@ class AdminClass extends BaseClass
         if (empty($right)) {
             util::fail("没有权限");
         }
+
+        // 判断 $newShop 是否本账号下的门店
+        $exit = ShopAdminClass::exists(['adminId'=>$admin->id, 'mainId'=>$newShop->mainId]);
+        if (!$exit) { // 不存在说明不是本账号下的门店,则直接返回
+            util::fail("切换的不是您的门店");
+        }
+
         $newShopId = $newShop->id ?? 0;
         $lsShopId = $newShop->lsShopId ?? 0;
         $shopAdmin = \biz\shop\classes\ShopAdminClass::changeShopAddRelate($originShopAdmin, $newShop);