mdmsoft / yii2-admin

Auth manager for Yii2 (RBAC Manager)
GNU General Public License v3.0
1.16k stars 577 forks source link

exception with message 'Trying to get property of non-object' when accessing public pages #202

Closed cloudeeo closed 9 years ago

cloudeeo commented 9 years ago

Hello, when trying to access public pages of my yii2 advanced application (e.g. home or login), I get an "Error #8 internal server error" message in the footer of the page and the log shows this error and stack

2015-09-11 08:41:42 [127.0.0.1][-][mfp6ig0mf83rhu8r24pg35g621][error][yii\base\ErrorException:8] exception 'yii\base\ErrorException' with message 'Trying to get property of non-object' in C:\Claudio\Web\HH\common\rbac\UserRule.php:31
Stack trace:
#0 C:\Claudio\Web\HH\vendor\yiisoft\yii2\rbac\DbManager.php(192): yii\rbac\BaseManager->executeRule()
#1 C:\Claudio\Web\HH\vendor\yiisoft\yii2\rbac\DbManager.php(206): yii\rbac\DbManager->checkAccessRecursive()
#2 C:\Claudio\Web\HH\vendor\yiisoft\yii2\rbac\DbManager.php(126): yii\rbac\DbManager->checkAccessRecursive()
#3 C:\Claudio\Web\HH\vendor\yiisoft\yii2\web\User.php(661): yii\rbac\DbManager->checkAccess()
#4 C:\Claudio\Web\HH\vendor\mdmsoft\yii2-admin\components\AccessControl.php(76): yii\web\User->can()
#5 C:\Claudio\Web\HH\vendor\yiisoft\yii2\base\ActionFilter.php(71): mdm\admin\components\AccessControl->beforeAction()
#6 C:\Claudio\Web\HH\vendor\yiisoft\yii2\base\Component.php(541): yii\base\ActionFilter->beforeFilter()
#7 C:\Claudio\Web\HH\vendor\yiisoft\yii2\base\Component.php(541): ::call_user_func:{C:\Claudio\Web\HH\vendor\yiisoft\yii2\base\Component.php:541}()
#8 C:\Claudio\Web\HH\vendor\yiisoft\yii2\base\Module.php(607): yii\base\Component->trigger()
#9 C:\Claudio\Web\HH\vendor\yiisoft\yii2\base\Controller.php(139): yii\base\Module->beforeAction()
#10 C:\Claudio\Web\HH\vendor\yiisoft\yii2\base\Module.php(455): yii\base\Controller->runAction()
#11 C:\Claudio\Web\HH\vendor\yiisoft\yii2\web\Application.php(84): yii\base\Module->runAction()
#12 C:\Claudio\Web\HH\vendor\yiisoft\yii2\base\Application.php(375): yii\web\Application->handleRequest()
#13 C:\Claudio\Web\HH\www\index.php(20): yii\base\Application->run()

The app configuration for access control is as follow:

'as access' => [
        'class' => 'mdm\admin\components\AccessControl',
        'allowActions' => [
            'site/*',            
        ]
        ,
    ],

It seems that the app is trying to get a user instance when no user is authenticated. This is why it fails in getting a user object. Any idea of the origin of the problem? thanks! Cheers Claudio

mdmunir commented 9 years ago

Its error when execute rule. Please check your existing rule

cloudeeo commented 9 years ago

Thanks the problem was exactly a rule!

Thanyathep commented 8 years ago

PHP User Error – yii\base\ErrorException. Please Help me