As in Yii 1.x, before performing the action of the controller, check: does the user have rights to perform this action and if he does not have to execute a certain code?
I try this in protected \ components \ Controller.php:
class Controller extends CController { protected function beforeAction($action) { if ( !Yii::app()->user->checkAccess($action->id) ) { // здесь мой код } return parent::beforeAction($action); } Unfortunately, the code does not work, because Yii::app()->user->checkAccess FALSE when it should be TRUE and vice versa.
What's wrong?