From 2d2cc7254681d1b77b9ce243ec918bf2a045f978 Mon Sep 17 00:00:00 2001 From: fomichev Date: Mon, 25 May 2026 11:03:01 +0300 Subject: [PATCH] =?utf8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BF?= =?utf8?q?=D0=BE=20=D0=B4=D1=83=D0=B1=D0=BB=D0=B8=D0=BA=D0=B0=D1=86=D0=B8?= =?utf8?q?=D0=B8=20=D0=BF=D1=80=D0=B8=20=D0=BD=D0=B0=D0=B7=D0=BD=D0=B0?= =?utf8?q?=D1=87=D0=B5=D0=BD=D0=B8=D0=B8=20=D0=BF=D1=80=D0=B0=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/commands/AuthController.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/erp24/commands/AuthController.php b/erp24/commands/AuthController.php index 1d857355..eca4b2d2 100644 --- a/erp24/commands/AuthController.php +++ b/erp24/commands/AuthController.php @@ -30,7 +30,10 @@ class AuthController extends Controller * @throws \Exception */ public function actionInit() { - $isDirty = Yii::$app->cache->get("dirtyAuthSettings") ?? true; + // cache->get() возвращает false и при промахе, и когда значение явно false — различить нельзя. + // Используем exists(): если ключа нет (flush или первый запуск) — запускаем на всякий случай. + $keyExists = Yii::$app->cache->exists("dirtyAuthSettings"); + $isDirty = !$keyExists || (bool)Yii::$app->cache->get("dirtyAuthSettings"); if (!$this->force && !$isDirty) { echo "Нет изменений в настройках разрешений\n"; return 'ok'; @@ -130,9 +133,13 @@ class AuthController extends Controller ['id' => $adminGroupRbacConfig->admin_group_id - (1e+6)] ])->all() as $admin) { if ($roleOrPermission) { - $auth->assign($roleOrPermission, $admin->id); + if (!$auth->getAssignment($roleOrPermission->name, $admin->id)) { + $auth->assign($roleOrPermission, $admin->id); + } } else { - $auth->assign($permission, $admin->id); + if (!$auth->getAssignment($permission->name, $admin->id)) { + $auth->assign($permission, $admin->id); + } } } } -- 2.39.5