我在CakePHP中使用ACL用户记录结果2.3.0-RC1CakePHP的2.0 ACL - 更新中ARO错误
当我更新用户字段(选择启用营销)我得到一个错误:
AclNode::node() - Couldn't find Aro node identified by "Array ([Aro0.model] => User[Aro0.foreign_key] => 4) "
我认为这与保存用户有关。我无法在手册中找到有关如何解决此问题的任何内容。
这里是从控制器剪断的方法:
$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错误后。
从未使用Aro,但是如果您执行'debug($ aro);'在页面上是包含任何无效数据的数组? – Grambot
看起来用户没有该对象的acl条目。 –
@ColbyGuyer是正确的,用户缺少ARO记录,因此你的ACL检查在试图找到它时会抛出错误。通常在ACL设置中,User模型具有添加ARO的afterSave。确保发生。 – jeremyharris