Answer the question
In order to leave comments, you need to log in
Why does yii2 hook the User model?
Here at this address (from bottom to top it is called)
<item>
#0 C:\OpenServer\domains\aparts\vendor\yiisoft\yii2\base\Object.php(107): yii\web\User->init()
</item>
<item>
#1 [internal function]: yii\base\Object->__construct(Array)
</item>
<item>
#2 C:\OpenServer\domains\aparts\vendor\yiisoft\yii2\di\Container.php(368): ReflectionClass->newInstanceArgs(Array)
</item>
<item>
#3 C:\OpenServer\domains\aparts\vendor\yiisoft\yii2\di\Container.php(153): yii\di\Container->build('yii\\web\\User', Array, Array)
</item>
<item>
#4 C:\OpenServer\domains\aparts\vendor\yiisoft\yii2\BaseYii.php(344): yii\di\Container->get('yii\\web\\User', Array, Array)
</item>
<item>
#5 C:\OpenServer\domains\aparts\vendor\yiisoft\yii2\di\ServiceLocator.php(133): yii\BaseYii::createObject(Array)
</item>
<item>
#6 C:\OpenServer\domains\aparts\vendor\yiisoft\yii2\web\Application.php(168): yii\di\ServiceLocator->get('user')
</item>
<item>
#7 C:\OpenServer\domains\aparts\vendor\yiisoft\yii2\filters\RateLimiter.php(70): yii\web\Application->getUser()
</item>
<item>
#8 C:\OpenServer\domains\aparts\vendor\yiisoft\yii2\base\ActionFilter.php(73): yii\filters\RateLimiter->beforeAction(Object(yii\rest\IndexAction))
</item>
<item>
#9 [internal function]: yii\base\ActionFilter->beforeFilter(Object(yii\base\ActionEvent))
</item>
<item>
#10 C:\OpenServer\domains\aparts\vendor\yiisoft\yii2\base\Component.php(541): call_user_func(Array, Object(yii\base\ActionEvent))
</item>
<item>
#11 C:\OpenServer\domains\aparts\vendor\yiisoft\yii2\base\Controller.php(269): yii\base\Component->trigger('beforeAction', Object(yii\base\ActionEvent))
</item>
<item>
#12 C:\OpenServer\domains\aparts\vendor\yiisoft\yii2\web\Controller.php(108): yii\base\Controller->beforeAction(Object(yii\rest\IndexAction))
</item>
<item>
#13 C:\OpenServer\domains\aparts\vendor\yiisoft\yii2\base\Controller.php(152): yii\web\Controller->beforeAction(Object(yii\rest\IndexAction))
</item>
<item>
#14 C:\OpenServer\domains\aparts\vendor\yiisoft\yii2\base\Module.php(454): yii\base\Controller->runAction('', Array)
</item>
<item>
#15 C:\OpenServer\domains\aparts\vendor\yiisoft\yii2\web\Application.php(84): yii\base\Module->runAction('apartments/test', Array)
</item>
<item>
#16 C:\OpenServer\domains\aparts\vendor\yiisoft\yii2\base\Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
</item>
<item>
#17 C:\OpenServer\domains\aparts\aparts\index.php(8): yii\base\Application->run()
</item>
Answer the question
In order to leave comments, you need to log in
found the answer: ActiveController before answering this or that request checks whether this user has rights to this action. And my user rights were undefined, just like the user class. I solved this problem simply by overloading the beforeAction() function, which checks this case.
There is a migration by default, deploy it. Out of the box comes the same model of users.
#9 [internal function]: yii\base\ActionFilter->beforeFilter(Object(yii\base\ActionEvent))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question