From 4c61ccbb65337d9852a3f07ccbf61cb823377c1c Mon Sep 17 00:00:00 2001 From: Arsen Mirzaev Tatyano-Muradovich Date: Mon, 29 Mar 2021 11:23:00 +1000 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 4 +-- composer.lock | 10 ++++--- .../skillparts/system/config/web.php.example | 6 ++--- .../controllers/AuthenticationController.php | 26 +++++++++--------- mirzaev/skillparts/system/models/Product.php | 1 + .../skillparts/system/views/product/index.php | 25 ++++++++++------- .../skillparts/system/views/profile/index.php | 18 ++++++++++--- .../system/views/profile/monitoring.php | 27 ++++++++++--------- .../system/views/profile/sidebar.php | 5 ++-- .../system/views/profile/supplies.php | 5 ++-- .../skillparts/system/views/search/index.php | 5 ++-- 11 files changed, 77 insertions(+), 55 deletions(-) diff --git a/composer.json b/composer.json index baafbf0..314e3ad 100644 --- a/composer.json +++ b/composer.json @@ -25,8 +25,8 @@ "moonlandsoft/yii2-phpexcel": ">=2.0", "carono/yii2-1c-exchange": "^0.3.1", "yiisoft/yii2-imagine": "*", - "mirzaev/yii2-arangodb": "2.1.x-dev", - "mirzaev/yii2-arangodb-sessions": "1.1.x-dev" + "mirzaev/yii2-arangodb": ">=2.1.x-dev", + "mirzaev/yii2-arangodb-sessions": ">=1.1.x-dev" }, "require-dev": { "codeception/codeception": ">=4.1", diff --git a/composer.lock b/composer.lock index 4d02379..65b4703 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "75801d98410f1427be988c04697ee255", + "content-hash": "ccecbc4681132b24e370af7c3db52dd8", "packages": [ { "name": "bower-asset/bootstrap", @@ -829,20 +829,22 @@ }, { "name": "mirzaev/yii2-arangodb-sessions", - "version": "1.1.x-dev", + "version": "dev-stable", "source": { "type": "git", "url": "https://git.hood.su/mirzaev/yii2/arangodb/sessions/", - "reference": "8809a05c1b0d1deff2fbcb25f6fd65f851029e78" + "reference": "80c16734945a35a0d49170b9a1a854efb322fefb" }, "require": { "mirzaev/yii2-arangodb": "~2.1.x-dev", "php": "^8.0.0", + "triagens/arangodb": "~3.2", "yiisoft/yii2": "2.*" }, "require-dev": { "yiisoft/yii2-debug": "*" }, + "default-branch": true, "type": "yii2-extension", "autoload": { "psr-4": { @@ -868,7 +870,7 @@ "DbSession", "yii2" ], - "time": "2021-03-21T18:58:00+00:00" + "time": "2021-03-21T18:39:52+00:00" }, { "name": "moonlandsoft/yii2-phpexcel", diff --git a/mirzaev/skillparts/system/config/web.php.example b/mirzaev/skillparts/system/config/web.php.example index d353c18..e649c10 100644 --- a/mirzaev/skillparts/system/config/web.php.example +++ b/mirzaev/skillparts/system/config/web.php.example @@ -24,9 +24,9 @@ $config = [ // 'enableAutoLogin' => true, 'enableSession' => true ], - 'authManager' => [ - 'class' => 'mirzaev\yii2\arangodb\rbac\DbManager', - ], + // 'authManager' => [ + // 'class' => 'mirzaev\yii2\arangodb\rbac\DbManager', + // ], 'session' => [ 'class' => 'mirzaev\yii2\arangodb\sessions\ArangoDbSession', 'document' => 'session', diff --git a/mirzaev/skillparts/system/controllers/AuthenticationController.php b/mirzaev/skillparts/system/controllers/AuthenticationController.php index ce388f9..95c99a6 100644 --- a/mirzaev/skillparts/system/controllers/AuthenticationController.php +++ b/mirzaev/skillparts/system/controllers/AuthenticationController.php @@ -4,7 +4,7 @@ namespace app\controllers; use app\models\AccountForm; -use Yii; +use yii; use yii\web\Controller; use yii\web\Response; use yii\filters\AccessControl; @@ -35,16 +35,16 @@ class AuthenticationController extends Controller public function actionIndex() { - if (Yii::$app->request->isAjax) { + if (yii::$app->request->isAjax) { // AJAX-POST-запрос // Инициализация - $model = new AccountForm(Yii::$app->request->post('AccountForm')); + $model = new AccountForm(yii::$app->request->post('AccountForm')); $model->scenario = $model::SCENARIO_AUTHENTICATION; - Yii::$app->response->format = Response::FORMAT_JSON; + yii::$app->response->format = Response::FORMAT_JSON; - if (!Yii::$app->user->isGuest || $model->authentication()) { + if (!yii::$app->user->isGuest || $model->authentication()) { // Аккаунт аутентифицирован // Создание сессии @@ -62,10 +62,10 @@ class AuthenticationController extends Controller 'notifications_panel', 'notifications_panel_full' )), - '_csrf' => Yii::$app->request->getCsrfToken() + '_csrf' => yii::$app->request->getCsrfToken() ]; - if (($cookies = Yii::$app->request->cookies)->has('redirect')) { + if (($cookies = yii::$app->request->cookies)->has('redirect')) { // Найдено cookie с переадресацией // Запись ответа @@ -85,11 +85,11 @@ class AuthenticationController extends Controller // $return['main'] = (new $controller())->$action(); // Очистка cookie - unset(Yii::$app->response->cookies['redirect']); + unset(yii::$app->response->cookies['redirect']); } else { // Не найдено cookie с переадресацией - if (Yii::$app->request->pathInfo === 'authentication' || Yii::$app->request->pathInfo === 'registration') { + if (yii::$app->request->pathInfo === 'authentication' || yii::$app->request->pathInfo === 'registration') { // Если клиент на промежуточном URI // Запись ответа @@ -102,18 +102,18 @@ class AuthenticationController extends Controller } else { // Аккаунт не аутентифицирован - Yii::$app->response->statusCode = 400; + yii::$app->response->statusCode = 400; return [ 'main' => $this->renderPartial('/account/index', compact('model')), 'redirect' => '/authentication', - '_csrf' => Yii::$app->request->getCsrfToken() + '_csrf' => yii::$app->request->getCsrfToken() ]; } } - if (!Yii::$app->user->isGuest) { - Yii::$app->response->redirect('/'); + if (!yii::$app->user->isGuest) { + yii::$app->response->redirect('/'); } else { return $this->render('/account/index'); } diff --git a/mirzaev/skillparts/system/models/Product.php b/mirzaev/skillparts/system/models/Product.php index d68294d..9b64290 100644 --- a/mirzaev/skillparts/system/models/Product.php +++ b/mirzaev/skillparts/system/models/Product.php @@ -460,6 +460,7 @@ class Product extends Document public static function searchByPartialCatn(string $catn, int $limit = 1, array $select = []): static|array|null { $query = self::find() + ->for('product') ->in('product_search') ->search(['catn' => $catn]) ->limit($limit) diff --git a/mirzaev/skillparts/system/views/product/index.php b/mirzaev/skillparts/system/views/product/index.php index a63601a..ab76d25 100644 --- a/mirzaev/skillparts/system/views/product/index.php +++ b/mirzaev/skillparts/system/views/product/index.php @@ -32,8 +32,9 @@ use app\models\Product; ?> user->identity->type === 'administrator' - || yii::$app->user->identity->type === 'moderator' + !yii::$app->user->isGuest + && (yii::$app->user->identity->type === 'administrator' + || yii::$app->user->identity->type === 'moderator') ) : ?>