为什么我的 CakePHP ARO 没有被创建?

发布于 2024-11-15 00:56:43 字数 1580 浏览 2 评论 0原文

我按照 CakePHP Cookbook 的简单 ACL 应用教程学习了一段时间,一切都很好。当我创建用户时,我的 ARO 也会自动创建,而且无需太多努力,我就可以向每个人授予正确操作的权限。

不过,我的应用程序现在变得更加复杂。当我创建“房地产经纪人”时,我在房地产经纪人模型的 afterSave 函数中为他们创建一个用户,如下所示:

App::import( 'Component', 'Auth' );
  $this->Auth = new AuthComponent();

  $this->User->create();
  $this->User->set(array(
    'username' => $this->data['Realtor']['email'],
    'password' => $this->Auth->password($this->data['Realtor']['password']),
    'usergroup_id' => 2,
    'realtor_num' => $this->id
  ));
  if ($this->User->save()) {
    $this->save(array('user_id'=>$this->User->id));
  } else { 
    //error 
  }

不幸的是,虽然这成功创建了用户,并且数据似乎都符合我的期望,但我似乎没有获得 ARO 的时间更长。

我的用户组模型包含行

var $actsAs = array('Acl' => array('type' => 'requester'));

除此之外,我不知道如何说服我的应用程序生成 ARO。
有什么我可以忘记的事情可以帮助我让我的 ACL 回到正轨吗?

编辑:

我在用户模型的 afterSave 中遇到了这个,这似乎引起了各种麻烦:(

function afterSave($created) {
    if (!$created) {
        $parent = $this->parentNode();
        $parent = $this->node($parent);
        $node = $this->node();
        $aro = $node[0];
        $aro['Aro']['parent_id'] = $parent[0]['Aro']['id'];
        $this->Aro->save($aro);
    }
}

由本文提供:http://mark-story.com/posts/view/auth-and-acl-automatically-updating-user-aros) 我不知道这是否会以某种方式弄乱我的 ARO 创建...可能教我添加随机代码片段,但至少没有完全理解他们在做什么!

I followed the CakePHP Cookbook's simple ACL application tutorial and for a while all way fine and dandy. When I created a user, my AROs were automagically created too, and without too much effort I was able to give everyone permissions for the correct actions.

My application has become more complex now though. When I create a "Realtor", I create a user for them in the Realtor model's afterSave function, like so:

App::import( 'Component', 'Auth' );
  $this->Auth = new AuthComponent();

  $this->User->create();
  $this->User->set(array(
    'username' => $this->data['Realtor']['email'],
    'password' => $this->Auth->password($this->data['Realtor']['password']),
    'usergroup_id' => 2,
    'realtor_num' => $this->id
  ));
  if ($this->User->save()) {
    $this->save(array('user_id'=>$this->User->id));
  } else { 
    //error 
  }

Unfortunately, while this is successfully creating users, and the data all seems to match up with my expectations, I'm seemingly no longer getting AROs.

My Usergroup model contains the line

var $actsAs = array('Acl' => array('type' => 'requester'));

Beyond that, I have no idea how I would persuade my application to generate an ARO.
Is there anything I could have forgotten, that would help me get my ACL back on track?

EDIT:

I had this in the User model's afterSave which seems to have been causing various kinds of trouble:

function afterSave($created) {
    if (!$created) {
        $parent = $this->parentNode();
        $parent = $this->node($parent);
        $node = $this->node();
        $aro = $node[0];
        $aro['Aro']['parent_id'] = $parent[0]['Aro']['id'];
        $this->Aro->save($aro);
    }
}

(courtesy of this article: http://mark-story.com/posts/view/auth-and-acl-automatically-updating-user-aros) I don't know if that would have been fouling up my ARO creation somehow... probably teach me to add in random code snippets without fully understanding what they're doing, at the very least!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帅冕 2024-11-22 00:56:43

好的,我是新手
我无法理解你的问题,但是
现在我将 Acl 组件与 alaxos acl 插件一起使用
我尝试了解修改后的树遍历算法
并为aro、aco、aro_aco、group表设置基本数据
以及插件的一些要求
我建议您使用这个

Ok I' m newbie
I can't understand your problem but
now I use Acl component with alaxos acl plugin
I try to understand of modified tree traversal algorithm
and set basic data for aro,aco,aro_aco,group table
and some requirement of plugin
I suggest you to use this

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文