[ 'class' => AccessControl::className(), 'except' => ['login', 'error'], 'rules' => [ [ 'allow' => true, 'roles' => ['@'] ], ], ], 'verbs' => [ 'class' => VerbFilter::className(), 'actions' => [ 'logout' => ['post'], 'delete-req' => ['post'] ], ], ]; } /** * @inheritdoc */ public function actions() { return [ 'error' => [ 'class' => 'yii\web\ErrorAction', ], ]; } public function actionIndex() { /* if (Yii::$app->user->can('site/index')) { } else { Yii::$app->getSession()->setFlash('error', 'Доступ закрыт..'); return $this->redirect('/'); } */ return $this->render('index'); } public function actionLogin() { if (!\Yii::$app->user->isGuest) { return $this->goHome(); } $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); } else { return $this->render('login', [ 'model' => $model, ]); } } public function actionLogout() { Yii::$app->user->logout(); return $this->goHome(); } /** * Displays Profile page. * * @return mixed */ public function actionProfile() { $model = new Profile(); $model->saveProfile(); return $this->render('profile', [ 'model' => $model, ]); } public function actionRequests($id = 0) { if($id != 0) { Option::markOld($id); $this->redirect(['site/requests']); } $query = Option::find()->where(['model' => 'Feedback', 'model_id' => 1, 'parent_id' => null]); $provider = new ActiveDataProvider([ 'query' => $query, 'pagination' => [ 'pageSize' => 2, ], 'sort' => [ 'defaultOrder' => [ 'created_at' => SORT_DESC ] ] ]); $data = $provider->getModels(); return $this->render('requests', [ 'dataProvider' => $provider ]); } public function actionDeleteReq($id) { $model = Option::findOne($id); if(!is_null($model) && $model->delete()) { return $this->redirect(['site/requests']); } else{ Yii::$app->session->setFlash('post_error', $model->getFirstErrors()); return $this->redirect('[site/requests]'); } } public function actionTest() { echo "
";
        //var_dump(Yii::$app->getAuthManager()->getRole('CHUVAK'));
        //var_dump(Yii::$app->getAuthManager()->assign(Yii::$app->getAuthManager()->getRole('CHUVAK'), Yii::$app->user->getId()));
        var_dump(Yii::$app->getAuthManager()->getRoles());
        echo "
"; return $this->render('index'); } }