yii2-podium icon indicating copy to clipboard operation
yii2-podium copied to clipboard

User::can working wrong when authManager is external (default yii2) component

Open eLFuvo opened this issue 7 years ago • 0 comments

I have configure external (default yii2) authManager component for podium forum as:

'modules' => [
        'podium' =>
            [
                'class' => 'bizley\podium\Podium',
                'userComponent' => 'user',
                'adminId' => 1,
                'rbacComponent' => 'authManager',                
            ],
    ],

I already have existing users, so I just added roles from the podium forum to them.

bizley\podium\models\User::can function is working wrong.


 public static function can($permissionName, $params = [], $allowCaching = true)
    {
        if (Podium::getInstance()->userComponent === true) {
            return Podium::getInstance()->user->can($permissionName, $params, $allowCaching);
        }
        if (!Podium::getInstance()->user->isGuest) {
            $user = static::findMe();
            if (empty($user)) {
                return false;
            }
            if ($allowCaching && empty($params) && isset($user->_access[$permissionName])) {
                return $user->_access[$permissionName];
            }
// in this place we must check access by inherited_id
->            $access = Podium::getInstance()->rbac->checkAccess($user->id, $permissionName, $params);
            if ($allowCaching && empty($params)) {
                $user->_access[$permissionName] = $access;
            }
            return $access;
        }
        return false;
    }

eLFuvo avatar May 26 '17 14:05 eLFuvo