douxiong2738 2017-07-05 11:40
浏览 76
已采纳

CakePHP 3.4 ACL和管理路由

I am setting up a project in the new cakephp 3.4.2. For a great role definition I am using the cakephp acl (https://github.com/mattmemmesheimer/cakephp-3-acl-example).

Since I've activated the admin routing, the acl won't recognize it and gives me an error.

My routing:

Router::prefix('admin', function ($routes) {
    $routes->connect('/', ['controller' => 'Users', 'action' => 'index']);
    $routes->extensions(['json', 'xml']);
    // All routes here will be prefixed with `/admin`
    // And have the prefix => admin route element added.
    $routes->fallbacks('DashedRoute');
});

Baking my admin files with:

bin/cake bake controller --prefix admin users
bin/cake bake template --prefix admin users

This is my error when trying to open /admin/users(/index):

Warning (512): DbAcl::check() - Failed ACO node lookup in permissions check. Node references:
Aro: Array
(
[Users] => Array
    (
        [id] => 1
        [username] => admin
        [group_id] => 1
        [created] => Cake\I18n\FrozenTime Object
            (
                [time] => 2017-07-05T09:14:25+00:00
                [timezone] => UTC
                [fixedNowTime] => 
            )

        [modified] => Cake\I18n\FrozenTime Object
            (
                [time] => 2017-07-05T09:20:52+00:00
                [timezone] => UTC
                [fixedNowTime] => 
            )

    )

)

Aco: controllers/Admin/Users/index [ROOT/vendor/cakephp/acl/src/Model/Table/PermissionsTable.php, line 91]
Code Context
Acl\Model\Table\PermissionsTable::check() - ROOT/vendor/cakephp/acl/src/Model/Table/PermissionsTable.php, line 91
Acl\Adapter\DbAcl::check() - ROOT/vendor/cakephp/acl/src/Adapter/DbAcl.php, line 80
Acl\Controller\Component\AclComponent::check() - ROOT/vendor/cakephp/acl/src/Controller/Component/AclComponent.php, line 120
Acl\Auth\ActionsAuthorize::authorize() - ROOT/vendor/cakephp/acl/src/Auth/ActionsAuthorize.php, line 41
Cake\Controller\Component\AuthComponent::isAuthorized() - CORE/src/Controller/Component/AuthComponent.php, line 536
Cake\Controller\Component\AuthComponent::authCheck() - CORE/src/Controller/Component/AuthComponent.php, line 317
Cake\Controller\Component\AuthComponent::startup() - CORE/src/Controller/Component/AuthComponent.php, line 268
Cake\Event\EventManager::_callListener() - CORE/src/Event/EventManager.php, line 414
Cake\Event\EventManager::dispatch() - CORE/src/Event/EventManager.php, line 391
Cake\Controller\Controller::dispatchEvent() - CORE/src/Event/EventDispatcherTrait.php, line 78
Cake\Controller\Controller::startupProcess() - CORE/src/Controller/Controller.php, line 506
Cake\Http\ActionDispatcher::_invoke() - CORE/src/Http/ActionDispatcher.php, line 114
Cake\Http\ActionDispatcher::dispatch() - CORE/src/Http/ActionDispatcher.php, line 93
Cake\Http\BaseApplication::__invoke() - CORE/src/Http/BaseApplication.php, line 78
Cake\Http\Runner::__invoke() - CORE/src/Http/Runner.php, line 65
Cake\Routing\Middleware\RoutingMiddleware::__invoke() - CORE/src/Routing/Middleware/RoutingMiddleware.php, line 59

I already tried to add the Admin route to the ACL with

bin/cake acl grant Groups.1 controllers/admin

Anyone an idea how to add the whole admin routing to acl Groups.1 (admin-group)?

Kind regards, Matt

  • 写回答

1条回答 默认 最新

  • douguai7291 2017-07-14 06:49
    关注

    Hi I have faced same problem and found that we have to sync ACOs table using this command bin/cake acl_extras aco_sync my problem resolved please try this and let

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥30 用arduino开发esp32控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿