【问题标题】:CakeDc: Users plugin group-only aclCakeDc:用户插件组仅限 acl
【发布时间】:2014-06-17 16:09:12
【问题描述】:

我想用 CakeDc 用户插件实现一个仅限组的 acl。我遵循了 cake 的“简单 Acl 控制器应用程序指南”。 我在用户模型上有以下内容:

public $belongsTo = array(
    'Role' => array(
        'className' => 'Role',
        'foreignKey' => 'role_id',
        'conditions' => '',
        'fields' => '',
        'order' => ''
    )
);

 public $actsAs = array('Acl' => array('type' => 'requester', 'enabled' => false));

 public function parentNode() {
    if (!$this->id && empty($this->data)) {
        return null;
    }
    if (isset($this->data['User']['role_id'])) {
        $roleId = $this->data['User']['role_id'];
    } else {
        $roleId = $this->field('role_id');
    }
    if (!$roleId) {
        return null;
    } else {
        return array('Role' => array('id' => $roleId));
    }
}

public function bindNode($user) {
    return array('model' => 'Model.Role', 'foreign_key' => $user['User']['role_id']);
}

我在角色模型上有这个:

public $actsAs = array('Acl' => array('type' => 'requester'));

public function parentNode() {
    return null;
}
    public $hasMany = array(
    'User' => array(
        'className' => 'User',
        'foreignKey' => 'role_id',
        'dependent' => false,
        'conditions' => '',
        'fields' => '',
        'order' => '',
        'limit' => '',
        'offset' => '',
        'exclusive' => '',
        'finderQuery' => '',
        'counterQuery' => ''
    )
);

我似乎没有工作,它仍然问我 aro。

AclNode::node() - Couldn't find Aro node identified by "Array ( [Aro0.model] => User [Aro0.foreign_key] => 51 ) "

我应该如何纠正他们的错误? 提前致谢。

【问题讨论】:

    标签: cakephp cakephp-2.0 acl cakedc


    【解决方案1】:

    在 User.php 中尝试:

    public function bindNode($user) {
        return array('model' => 'Role', 'foreign_key' => $user['User']['role_id']);
    }
    

    而不是

    public function bindNode($user) {
        return array('model' => 'Model.Role', 'foreign_key' => $user['User']['role_id']);
    }
    

    【讨论】:

      【解决方案2】:

      AuthComponent 的授权方法设置userModel。它的名称不是标准的(用户),因为您正在扩展 Users 组件的用户模型。然而,Auth 和 Acl 必须知道。

      【讨论】:

        猜你喜欢
        • 2019-02-01
        • 2012-05-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-05-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多