cancel
Showing results for 
Search instead for 
Did you mean: 

Add new company role permission for existing roles

Add new company role permission for existing roles

Hi,
I created a patch that add new permission in table company_permissions for specific roles, the problem is when i go to role edit page checkbox not show value from database, i have four roles with same resources but different permissions, and for all is showed only value for last role, i found that function retrieveRolePermissions from PermissionProvider return wrong data and i created a plugin to rewrite this, but i don't understand why default magento function don't work properly.
This happens only with existing companies for that i add new permission, when i create a new company and role and permissions are installed default, all is good

3 REPLIES 3

Re: Add new company role permission for existing roles

I'm having the exact same issue. Magento\Company\Model\Authorization\PermissionProvider::retrieveRolePermissions() is not actually filtering by role_id. It appears the collection is already loaded prior to the filter being added, so it doesn't attempt to load it afterwards.

Re: Add new company role permission for existing roles

The problem is that when you add a new permission for existing company roles, the checkbox on the role edit page doesn't show the correct permissions. This only happens for existing companies, not new ones.
You found that the function in Magento that gets role permissions (called "retrieveRolePermissions") isn't working correctly. You created a fix for it, but it's strange that Magento's original function doesn't work as expected.

Re: Add new company role permission for existing roles

Hi,

Can you share your fix?