1

I'm having a Parent Role id "user" does not exist error

What I'm trying to get BjyAuthorize to work. In my config, I have

'bjyauthorize' => array(
    // Using the authentication identity provider, which basically reads the roles from the auth service's identity
    'identity_provider' => 'BjyAuthorize\Provider\Identity\AuthenticationIdentityProvider',

    'resource_providers' => [
        'BjyAuthorizeProviderResourceConfig' => [
            'user' => [],

        ],
    ],

    'role_providers'        => array(
        // using an object repository (entity repository) to load all roles into our ACL
        'BjyAuthorize\Provider\Role\ObjectRepositoryProvider' => array(
            'object_manager'    => 'doctrine.entity_manager.orm_default',
            'role_entity_class' => 'SorgcaUser\Entity\Role',
        ),


        'BjyAuthorizeProviderResourceConfig' => array(
            'allow' => array(
                array('user', 'admin', 'manage'),
            ),
        ),
    ),
),

In my controller I would simply call $this->isAllowed('admin', 'manage');

Now, calling isAllowed function will throw the error saying my Parent Role id does not exist

But, in my user_role table, I have

enter image description here

I'm not really sure how to begin debugging. Please advice.

juworld
  • 140
  • 1
  • 15
  • 1
    it prob has to be the other way arround. Give the guest the parent 'null' and the user the parent guest. – cptnk Sep 25 '14 at 09:50
  • Hi cptnk! Thanks for the tip. I just tried but it is throwing the same error. I noticed that my table doesn't have a `id` field. I'm also thinking, maybe it didn't know to look for user_role table. Is that possible? Do I need to tell the configuration to look for this table? – juworld Sep 25 '14 at 10:05
  • I am not 100% sure myself but this might be the issue. I usually use a zf2 module from sam that map's byj doctrine and zfc user together. Within there I provide a entity with a role definition. But I do suspect that the parent column is pretty much a foreign key calling it's own table and check for the 'id'. You might just want to add a id column with primary and autoincrement. This most likely will solve your issues. If you want to change the Role provider take a look at "BjyAuthorize\Service\RoleDbTableGateway" and override it to your needs. Hope that helps. – cptnk Sep 25 '14 at 12:25
  • Hi cptnk! Thanks for your help. I did try to rebuild my application using Sam's step by step instructions and now it works. Sorry I wasn't able to figure out what went wrong to help others who might experienced the same problem. – juworld Sep 29 '14 at 03:06

0 Answers0