gpt4 book ai didi

mysql - CakePHP Acl 控制的应用程序 ARO/ACO 查找失败 - 权限未注册

转载 作者:行者123 更新时间:2023-11-29 02:28:39 26 4
gpt4 key购买 nike

我正在构建一个基于配置文件的应用程序。我正在尝试使用此处找到的简单的 acl 控制应用程序教程:http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-controlled-application/simple-acl-controlled-application.html , 创建我的组和权限。当以不同用户身份登录时,我在获取运行权限时遇到了一些问题。我有一个管理员、经理和用户组。我已经设置了 ACO 和 ARO,并为每个组添加了权限。这是我的

class AppController extends Controller {

public $components = array(
'Acl',
'Auth'=>array(
'loginRedirect'=>array('controller'=>'users', 'action'=>'index'),
'logoutRedirect'=>array('controller'=>'users', 'action'=>'index'),
'authError'=>'You cannot access that page',
'authorize'=>array('actionPath' => 'controllers')
),
'Session'
);

public function isAuthorized($user) {
return true;
}

public function beforeFilter() {
$this->Auth->authorize = array(
'Actions' => array(
'userModel' => 'User',
'actionPath' => 'users'
)
);

$this->Auth->allow('display');

$this->set('logged_in', $this->Auth->loggedIn());
$this->set('current_user', $this->Auth->user());

}

}

用户 Controller .php

class UsersController extends AppController {

public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('view');
}



public function login() {
if ($this->request->is('Post')) {
if ($this->Auth->login()) {
$this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash('Your username/password combination was incorrect');
}
}
}

public function logout() {
$this->redirect($this->Auth->logout());
}

我现在得到的错误是:

Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:
Aro: Array
Permission::check() - CORE/Cake/Model/Permission.php, line 94
DbAcl::check() - CORE/Cake/Controller/Component/Acl/DbAcl.php, line 73
AclComponent::check() - CORE/Cake/Controller/Component/AclComponent.php, line 109
ActionsAuthorize::authorize() - CORE/Cake/Controller/Component/Auth/ActionsAuthorize.php, line 40
AuthComponent::isAuthorized() - CORE/Cake/Controller/Component/AuthComponent.php, line 412
AuthComponent::startup() - CORE/Cake/Controller/Component/AuthComponent.php, line 336
ObjectCollection::trigger() - CORE/Cake/Utility/ObjectCollection.php, line 132
call_user_func - [internal], line ??
CakeEventManager::dispatch() - CORE/Cake/Event/CakeEventManager.php, line 248
Controller::startupProcess() - CORE/Cake/Controller/Controller.php, line 671
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 184
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 162
[main] - APP/webroot/index.php, line 109

出于某种原因,它无法访问权限。而且我似乎找不到解决此问题的解决方案。任何帮助都会很棒!提前致谢!

最佳答案

这些错误通常是因为您在 Controller 中添加了函数/方法,但没有重新填充 acos 和 aros_acos 表。

您需要填充您的 acos 表

./Console/cake AclExtras.AclExtras aco_sync

http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-controlled-application/part-two.html

填充后,我们需要将这个新方法的权限分配给我们的 aros_acos 表

$this->Acl->allow($group, 'controllers/Posts/myNewCustomMethod');

然后再次运行 initDB 函数。教程一步步讲的很清楚。

关于mysql - CakePHP Acl 控制的应用程序 ARO/ACO 查找失败 - 权限未注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16638890/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com