2amigos / yii2-usuario

Highly customizable and extensible user management, authentication, and authorization Yii2 extension
https://github.com/2amigos/yii2-usuario
Other
294 stars 142 forks source link

Getting unknown property: Da\User\Model\User::isGuest #454

Closed derekisbusy closed 2 years ago

derekisbusy commented 2 years ago

isGuest property is not implemented in the User model? Do I have to add this myself?

EndErr commented 2 years ago

You should use: Yii::$app->user->isGuest

derekisbusy commented 2 years ago
in C:\www\testapp\app\vendor\yiisoft\yii2\db\BaseActiveRecord.php at line 296– [yii\base\Component::__get](http://www.yiiframework.com/doc-2.0/yii-base-component.html#__get()-detail)('isGuest')
3. in C:\www\testapp\app\vendor\yiisoft\yii2-debug\src\panels\UserPanel.php at line 83– [yii\db\BaseActiveRecord::__get](http://www.yiiframework.com/doc-2.0/yii-db-baseactiverecord.html#__get()-detail)('isGuest')
/**
     * {@inheritdoc}
     * @throws InvalidConfigException
     */
    public function init()
    {
        if (!$this->isEnabled() || $this->getUser()->isGuest) {
            return;
        }

        $this->userSwitch = new UserSwitch(['userComponent' => $this->userComponent]);
        $this->addAccessRules();

4. in C:\www\testapp\app\vendor\yiisoft\yii2\base\BaseObject.php at line 109– [yii\debug\panels\UserPanel::init](http://www.yiiframework.com/doc-2.0/yii-debug-panels-userpanel.html#init()-detail)()

its being called from the debug panel in Yii2. It should work out the box. I see isGuest is something thats not implemented in the User class of Usario... is this something I have to extend and implement myself? Where is it supposed to be implemented?

maxxer commented 2 years ago

It's implemented in Yii's User.php, but at the moment I cannot figure out the inheritance on how it reaches Usuario's user model, anyway we regularly use it in our apps

https://github.com/yiisoft/yii2/blob/6599713d2bcf4440190cec2b950b1738d7ddfae4/framework/web/User.php#L364-L367

derekisbusy commented 2 years ago

I fixed it. Forgot how but it was due to an RBAC extension not Usario.

twinpigs commented 2 years ago

I fixed it. Forgot how but it was due to an RBAC extension not Usario.

Nice! Can't You please remember how exactly? A'm in the same trouble just now (