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 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。