首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ARO2.0ACL-更新用户记录导致CakePHP错误

ARO2.0ACL-更新用户记录导致CakePHP错误
EN

Stack Overflow用户
提问于 2012-12-13 23:10:37
回答 2查看 655关注 0票数 3

我在CakePHP 2.3.0-RC1中使用ACL

当我更新用户字段(选择营销)时,我得到一个错误:

代码语言:javascript
复制
AclNode::node() - Couldn't find Aro node identified by "Array ( [Aro0.model] => User[Aro0.foreign_key] => 4 ) "

我认为这与拯救用户有关。我在手册中找不到任何关于如何解决这个问题的内容。

下面是从Controller中截取的方法:

代码语言:javascript
复制
$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错误。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-06-24 21:02:17

根据评论,我只是写这篇文章作为答案。

我将用户模型设置为请求者,但实际上打算在相关的“组”模型上使用基于角色的身份验证。

我设置了父节点,但忽略了从用户模型中删除作为请求者的行为。

注释出来的效果很不错--我实际上并不需要用户(只是组)的ARO对象,它之所以存在,只是因为Cake教程包含了它。

票数 1
EN

Stack Overflow用户

发布于 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指令

代码语言:javascript
复制
public $actsAs = array('Acl' => array('type' => 'requester', 'enabled' => false));

在用户模型中,以防您打算仅具有组ACL。并且您必须实现bind方法:

代码语言:javascript
复制
public function bindNode($user) {
return array('model' => 'Group', 'foreign_key' => $user['User']['group_id']);

}

这对我很有效。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13862744

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档