Nested roles in BjyAuthorize\Provider\Role\Config

91 views Asked by At

I am trying to create nested roles, where the developer is the role that can have access to all the controller/action, here is my genealogy layout:

 'role_providers'        => array(

        'BjyAuthorize\Provider\Role\Config' => array(
            'guest'  => array('children' => array(

                'programador' => array(
                    'children'=>array(
                        'administration'=>array('children'=>array('developer'=>array())),
                    )
                ),
                'conclidiador' => array(
                    'children'=>array(
                        'administration'=>array('children'=>array('developer'=>array())),
                    )
                ),
                'tesorero' => array(
                    'children'=>array(
                        'administration'=>array('children'=>array('developer'=>array())),
                    )
                ),
            )),
        ),
 ),

This does not work.

It works fine if I just leave one.

    'role_providers'        => array(

        'BjyAuthorize\Provider\Role\Config' => array(
            'guest'  => array('children' => array(

                'programador' => array(
                    'children'=>array(
                        'administration'=>array('children'=>array('developer'=>array())),
                    )
                ),     
            )),
        ),
    ),

I will like developer to have access to everything then administration and then the rest programador,conclidiador, tesorero on the same level and at the end guest.

1

There are 1 answers

1
JI-Web On

I'm trying to a similar thing but have a different style in by config file:

'BjyAuthorize\Provider\Role\Config' => [
            'guest' => [],
            'user'  => ['children' => [
                'admin' => [],
                'member' => ['children' => [
                    'membervip' => []
                ]],
                'merchant' => ['children' => [
                    'merchantvip'   => []   
                ]],
                'player' => ['children' => [
                    'playerplus'    => []   
                ]]
            ]],
        ],

I've also had to adjust the table 'user_role' to correspond to the above layout/config have the correct 'user_role'.'parent_id' values as above

Therefore, I'd assume you would need something like this:

'BjyAuthorize\Provider\Role\Config' => [
            'guest' => [],
            'user'  => ['children' => [
                'programador' => [],
                'conclidiador' => [],
                'tesorero' => [],
                'administrator' => ['children' => [
                   'developer' => []
                 ]]
            ]],
        ],

That was the parent 'user' has the same level as all. Then define the permissions to that level in your route/controller gaurds. 'user' is the base access to all sub roles, then the split is in 'administrator'