From 6812f2333e5e655f1ce49e53489aa1864a91cd40 Mon Sep 17 00:00:00 2001 From: Kavalar Date: Sun, 26 May 2024 12:52:52 +0300 Subject: [PATCH] auth --- .../controllers/AddressesController.php | 28 +++++--- .../check/controllers/CheckController.php | 29 +++++--- .../company/controllers/CompanyController.php | 70 +++++++++---------- .../product/controllers/ProductController.php | 28 +++++--- .../controllers/ProductCategoryController.php | 28 +++++--- 5 files changed, 116 insertions(+), 67 deletions(-) diff --git a/frontend/modules/addresses/controllers/AddressesController.php b/frontend/modules/addresses/controllers/AddressesController.php index dbd10b7..7d4bf93 100644 --- a/frontend/modules/addresses/controllers/AddressesController.php +++ b/frontend/modules/addresses/controllers/AddressesController.php @@ -24,18 +24,30 @@ class AddressesController extends Controller } /** - * {@inheritdoc} + * @inheritDoc */ public function behaviors() { - return [ - 'verbs' => [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], + return array_merge( + parent::behaviors(), + [ + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], ], - ], - ]; + 'access' => [ + 'class' => \yii\filters\AccessControl::className(), + 'rules' => [ + [ + 'allow' => true, + 'roles' => ['@'], + ], + ], + ], + ] + ); } /** diff --git a/frontend/modules/check/controllers/CheckController.php b/frontend/modules/check/controllers/CheckController.php index f4369b7..6fcd917 100644 --- a/frontend/modules/check/controllers/CheckController.php +++ b/frontend/modules/check/controllers/CheckController.php @@ -14,19 +14,32 @@ use yii\filters\VerbFilter; */ class CheckController extends Controller { + /** - * {@inheritdoc} + * @inheritDoc */ public function behaviors() { - return [ - 'verbs' => [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], + return array_merge( + parent::behaviors(), + [ + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], ], - ], - ]; + 'access' => [ + 'class' => \yii\filters\AccessControl::className(), + 'rules' => [ + [ + 'allow' => true, + 'roles' => ['@'], + ], + ], + ], + ] + ); } /** diff --git a/frontend/modules/company/controllers/CompanyController.php b/frontend/modules/company/controllers/CompanyController.php index 1d10bc2..56730f1 100644 --- a/frontend/modules/company/controllers/CompanyController.php +++ b/frontend/modules/company/controllers/CompanyController.php @@ -26,44 +26,44 @@ class CompanyController extends Controller /** * {@inheritdoc} */ - public function behaviors() - { - return [ - 'verbs' => [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], - ], - ], - ]; - } +// public function behaviors() +// { +// return [ +// 'verbs' => [ +// 'class' => VerbFilter::className(), +// 'actions' => [ +// 'delete' => ['POST'], +// ], +// ], +// ]; +// } /** * @inheritDoc */ -// public function behaviors() -// { -// return array_merge( -// parent::behaviors(), -// [ -// 'verbs' => [ -// 'class' => VerbFilter::className(), -// 'actions' => [ -// 'delete' => ['POST'], -// ], -// ], -// 'access' => [ -// 'class' => \yii\filters\AccessControl::className(), -// 'rules' => [ -// [ -// 'allow' => true, -// 'roles' => ['@'], -// ], -// ], -// ], -// ] -// ); -// } + public function behaviors() + { + return array_merge( + parent::behaviors(), + [ + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + 'access' => [ + 'class' => \yii\filters\AccessControl::className(), + 'rules' => [ + [ + 'allow' => true, + 'roles' => ['@'], + ], + ], + ], + ] + ); + } /** * Lists all Company models. @@ -108,7 +108,7 @@ class CompanyController extends Controller if ($model->load($this->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } - Debug::prn($model); + Debug::prn($model->errors); } else { $model->loadDefaultValues(); } diff --git a/frontend/modules/product/controllers/ProductController.php b/frontend/modules/product/controllers/ProductController.php index 1b33516..b05789d 100644 --- a/frontend/modules/product/controllers/ProductController.php +++ b/frontend/modules/product/controllers/ProductController.php @@ -24,18 +24,30 @@ class ProductController extends Controller } /** - * {@inheritdoc} + * @inheritDoc */ public function behaviors() { - return [ - 'verbs' => [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], + return array_merge( + parent::behaviors(), + [ + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], ], - ], - ]; + 'access' => [ + 'class' => \yii\filters\AccessControl::className(), + 'rules' => [ + [ + 'allow' => true, + 'roles' => ['@'], + ], + ], + ], + ] + ); } /** diff --git a/frontend/modules/product_category/controllers/ProductCategoryController.php b/frontend/modules/product_category/controllers/ProductCategoryController.php index 6a11450..61d2a4f 100644 --- a/frontend/modules/product_category/controllers/ProductCategoryController.php +++ b/frontend/modules/product_category/controllers/ProductCategoryController.php @@ -27,18 +27,30 @@ class ProductCategoryController extends Controller } /** - * {@inheritdoc} + * @inheritDoc */ public function behaviors() { - return [ - 'verbs' => [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], + return array_merge( + parent::behaviors(), + [ + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], ], - ], - ]; + 'access' => [ + 'class' => \yii\filters\AccessControl::className(), + 'rules' => [ + [ + 'allow' => true, + 'roles' => ['@'], + ], + ], + ], + ] + ); } /**