我在CakePHP 2.3.0-RC1中使用ACL
当我更新用户字段(选择营销)时,我得到一个错误:
AclNode::node() - Couldn't find Aro node identified by "Array ( [Aro0.model] => User[Aro0.foreign_key] => 4 ) "我认为这与拯救用户有关。我在手册中找不到任何关于如何解决这个问题的内容。
下面是从Controller中截取的方法:
$me = $this->Session->read('Auth.User');
// don't use the session to display, because they might have subscribed/unsubscribed
$user = $this->User->find('first',array('conditions'=>array('User.id'=>$me['id'])));
$optin = ! $user['User']['optin'];
$data = array(
'User' => array(
'id' => $me['id'],
'optin' => $optin
)
);
if ( $this->User->save($data) )
{
$this->Session->setFlash(__('Subscription status has been amended'));
}
else
{
$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
}
$this->redirect(array('action'=>'account'));在重定向之后,我得到了ARO错误。
发布于 2013-06-24 21:02:17
根据评论,我只是写这篇文章作为答案。
我将用户模型设置为请求者,但实际上打算在相关的“组”模型上使用基于角色的身份验证。
我设置了父节点,但忽略了从用户模型中删除作为请求者的行为。
注释出来的效果很不错--我实际上并不需要用户(只是组)的ARO对象,它之所以存在,只是因为Cake教程包含了它。
发布于 2014-04-15 18:59:32
当前教程(http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-controlled-application/simple-acl-controlled-application.html)建议禁用requester指令
public $actsAs = array('Acl' => array('type' => 'requester', 'enabled' => false));在用户模型中,以防您打算仅具有组ACL。并且您必须实现bind方法:
public function bindNode($user) {
return array('model' => 'Group', 'foreign_key' => $user['User']['group_id']);}
这对我很有效。
https://stackoverflow.com/questions/13862744
复制相似问题