【问题标题】:Cakephp: Setting up ACL allow specific action and deny the rest of actions from controllerCakephp:设置 ACL 允许特定操作并拒绝控制器的其余操作
【发布时间】:2012-12-16 19:16:49
【问题描述】:

我正在尝试设置 cakephp ACL 权限。

public function initDB() {
$group = $this->User->Group;
//root
$group->id = 1;
$this->Acl->allow($group, 'controllers');
//admin
$group->id = 2;
$this->Acl->allow($group, 'controllers/Users');

//cliente
$group->id = 3;
$this->Acl->deny($group, 'controllers');
$this->Acl->allow($group, 'controllers/Pages');
PROBLEM BELOW ----------------------------------------------
$this->Acl->allow($group, 'controllers/Users/trocar_senha/')
echo "all done";
exit;
}

这也否认了用户的“trocar_senha”操作。但我想允许这样做并拒绝用户控制器的所有休息操作。

如何允许特定操作并拒绝控制器的所有其他操作?

谢谢!

【问题讨论】:

    标签: php cakephp acl cakephp-2.1


    【解决方案1】:

    解决了! 问题是$this->Acl->allow($group, controllers/Users/trocar_senha/') 上的斜线。

    public function initDB() {
        $group = $this->User->Group;
        //root
        $group->id = 1;
        $this->Acl->allow($group, 'controllers');
        //admin
        $group->id = 2;
        $this->Acl->allow($group, 'controllers/Users');
    
        //cliente
        $group->id = 3;
        $this->Acl->deny($group, 'controllers');
        $this->Acl->allow($group, 'controllers/Pages');
        $this->Acl->allow($group, 'controllers/Users/trocar_senha'); // WHITHOUT SLASH
        echo "all done";
        exit;
    }
    

    【讨论】:

      猜你喜欢
      • 2014-03-15
      • 1970-01-01
      • 1970-01-01
      • 2017-06-11
      • 2013-09-22
      • 1970-01-01
      • 1970-01-01
      • 2011-12-17
      • 1970-01-01
      相关资源
      最近更新 更多