]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
delete session if required data not exists
authorpavlikov_maxim <truobleblyat@yandex.ru>
Sat, 27 Apr 2024 11:37:53 +0000 (14:37 +0300)
committerpavlikov_maxim <truobleblyat@yandex.ru>
Sat, 27 Apr 2024 11:37:53 +0000 (14:37 +0300)
erp24/controllers/SiteController.php

index ad1c3a98e2279dd08f77a38ca01cb8a257a20b69..a1e8a9b54144233b261abd2c89425d7c792f4318 100644 (file)
@@ -47,11 +47,18 @@ class SiteController extends Controller
     /**
      * Displays homepage.
      *
-     * @return string
+     * @return string|Response
      */
     public function actionIndex()
     {
-        return $this->render('index');
+        $session = Yii::$app->session;
+        if (isset($session['view_modules'])) {
+            return $this->render('index');
+        } else {
+            // если нет нужных данных, удаляем сессию и отправляем на главную
+            $session->destroy();
+            return $this->goHome();
+        }
     }
 
     /**
@@ -122,7 +129,8 @@ class SiteController extends Controller
         return $this->render('about');
     }
 
-    public function actionMenuTree() {
+    public function actionMenuTree()
+    {
 //        $client = new Client(['base_uri' => Yii::$app->params['API2_URL']]);
 //        $response = $client->request('GET', '/site/menu-tree?user_id=' . Yii::$app->user->id . '&key=' . Yii::$app->params['API2_TOKEN']);
 //        return $this->asJson(json_decode($response->getBody(), true));