0

我正在尝试设置 cakephp ACL 权限。

public function initDB() {
$group = $this->User->Group;
//root
$group->id = 1;
$this->Acl->allow($group, 'controllers');
//admin
$group->id = 2;
$this->Acl->allow($group, 'controllers/Users');

//cliente
$group->id = 3;
$this->Acl->deny($group, 'controllers');
$this->Acl->allow($group, 'controllers/Pages');
PROBLEM BELOW ----------------------------------------------
$this->Acl->allow($group, 'controllers/Users/trocar_senha/')
echo "all done";
exit;
}

这也否认了用户的行动“trocar_senha”。但我想允许这样做并拒绝用户控制器的所有休息操作。

如何允许特定操作并拒绝控制器的所有其余操作?

谢谢!

4

1 回答 1

0

解决了!问题是斜线$this->Acl->allow($group, controllers/Users/trocar_senha/')

public function initDB() {
    $group = $this->User->Group;
    //root
    $group->id = 1;
    $this->Acl->allow($group, 'controllers');
    //admin
    $group->id = 2;
    $this->Acl->allow($group, 'controllers/Users');

    //cliente
    $group->id = 3;
    $this->Acl->deny($group, 'controllers');
    $this->Acl->allow($group, 'controllers/Pages');
    $this->Acl->allow($group, 'controllers/Users/trocar_senha'); // WHITHOUT SLASH
    echo "all done";
    exit;
}
于 2012-12-16T20:50:44.533 回答