CakePHP:设置ACL允许/拒绝不工作(表格未更新)?
问题描述:
我试图建立我的ACL在我UsersController了以下行动:CakePHP:设置ACL允许/拒绝不工作(表格未更新)?
class UsersController extends AppController {
var $name = 'Users';
var $helpers = array('Html', 'Form');
function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('*');
}
function install() {
$group =& $this->User->Group;
//Allow admins to everything
$group->id = 1;
$this->Acl->allow($group, 'controllers');
//allow users
$group->id = 2;
$this->Acl->deny($group, 'controllers');
$this->Acl->allow($group, 'controllers/Messages');
$this->Acl->allow($group, 'controllers/MessageLists');
$this->Acl->allow($group, 'controllers/Products');
$this->Acl->allow($group, 'controllers/Widgetviews');
}
所以我跟着localhost/users/install
,并在功能呼应一些数字之后,我意识到它跑。然而,蛋糕给我下面的错误:
Error: The requested address '/users/install' was not found on this server.
我真的不知道是什么问题,但我的ACOS /阿罗斯/ aros_acos表都是在此之后保持不变。下面是从下列查询自己的数据:
mysql> select * from aros_acos a join acos c on a.aco_id=c.id join aros r on a.a
ro_id=r.id
-> ;
+----+--------+--------+---------+-------+---------+---------+----+-----------+-------+-------------+-------------+------+------+----+-----------+-------+-------------+-------+------+------+
| id | aro_id | aco_id | _create | _read | _update | _delete | id | parent_id | model | foreign_key | alias | lft | rght | id | parent_id | model | foreign_key | alias | lft | rght |
+----+--------+--------+---------+-------+---------+---------+----+-----------+-------+-------------+-------------+------+------+----+-----------+-------+-------------+-------+------+------+
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | NULL | NULL | NULL | controllers | 1 | 2 | 1 | NULL | Group | 1 | NULL | 1 | 4 |
| 2 | 2 | 1 | -1 | -1 | -1 | -1 | 1 | NULL | NULL | NULL | controllers | 1 | 2 | 2 | NULL | Group | 2 | NULL | 5 | 10 |
| 3 | 1 | 2 | 1 | 1 | 1 | 1 | 2 | NULL | NULL | NULL | controllers | 3 | 4 | 1 | NULL | Group | 1 | NULL | 1 | 4 |
| 4 | 2 | 2 | -1 | -1 | -1 | -1 | 2 | NULL | NULL | NULL | controllers | 3 | 4 | 2 | NULL | Group | 2 | NULL | 5 | 10 |
+----+--------+--------+---------+-------+---------+---------+----+-----------+-------+-------------+-------------+------+------+----+-----------+-------+-------------+-------+------+------+
4 rows in set (0.00 sec)
编辑: 我已经调试设置为0,所以它切换到2后,我收到以下警告:
Warning (512): AclNode::node() - Couldn't find Aro node identified by "Array
(
[Aro0.model] => Group
[Aro0.foreign_key] => 1
)
" [CORE\cake\libs\model\db_acl.php, line 191]
Warning (512): DbAcl::allow() - Invalid node [CORE\cake\libs\controller\components\acl.php, line 324]
Warning (512): AclNode::node() - Couldn't find Aro node identified by "Array
(
[Aro0.model] => Group
[Aro0.foreign_key] => 2
)
" [CORE\cake\libs\model\db_acl.php, line 191]
我还重创建了我的DbAcl,它填充了acos
表,但不包含aros
或aros_acos
表。上面的警告是我正在尝试再次运行install
操作。
答
我认为你必须为控制器/消息等创建ACO,然后才能分配权限。
将您的调试级别设置为app/config/core.php
以获得更好的错误消息。 “生产”设置使得Cake为每个错误提供相同的信息。
答
你试试这个命令:
../cake/console/cake ACL创建ARO根组
../cake/console/cake ACL创建ARO根Group.1
../cake/console/cake ACL创建ARO根Group.2
../cake/console/cake ACL创建ARO根Group.3
我一定是把它关闭在星期五:\我”我用警告更新了我的帖子。 – Garrett 2012-01-09 19:30:16
这是我的坏 - 我只需重新创建组和用户后,我重新创建了DbAcl,以便他们将注册为ARO。谢谢! – Garrett 2012-01-09 20:01:30