Permissions on multi-tenancy app #1777
Replies: 5 comments 1 reply
-
|
It's been awhile. Did you come up with a solution to your issue? |
Beta Was this translation helpful? Give feedback.
-
|
I have the same problem, I am using the hyn tenancy package, when I consult the user and the role everything is fine, when I consult for the permissions of that user everything is fine, but when I search for a specific permission, and even when I pass the middleware of the permissions in the constructor, it generates the error |
Beta Was this translation helpful? Give feedback.
-
|
I ran in to the same problem and solved it by creating my own Then I changed the permission.php config to point to the new models. |
Beta Was this translation helpful? Give feedback.
-
|
What about Permission and Role in SystemConnection? because you are overwriting permission.php models connection |
Beta Was this translation helpful? Give feedback.
-
|
Just to let everyone know that I couldn't resolve this issue so I had to remove the role/permissions from the system level and only apply it only on the tenant level. Seems that no one else managed to find a solution to the problem... If there is any that is. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a 2 tier tenancy app where a system user can spin up client environments with their own db instances. Based on this implementation, I have created a combo of
Role+Permissionmodels on theApp\Modelsand theApp\Tenant\Modelsdirectories respectively. The twoRolemodels are extensions of Spatie'sRoleimplementation and the twoPermissionmodels are extensions ofPermissionimplementation. The tenant models useForTenantstrait that defines the database connection as well as the$guard_nameproperty. You can view the Role implementation below (similar approach is followed forPermissionmodels).Based on the docs, I have to specify the model names in the
permission.phpconfig in order for the code to know which one to use. The problem as you might have guessed by now is that in order for my implementation to work, I need to support two different model versions depending on the guard and not lock the config by pointing to a specific model version i.e. system or tenant. A solution would have been to update thepermission.models.permissionandpermission.models.roleconfig values during runtime but that did not work:The weird thing is if I try to do a
dd($user->hasPermissionTo('manage own users'));inside theviewAnyPolicy method, it will show me the following error:and doing
dd($user->permissions);I get an empty array, but if I dodd($user->getAllPermissions());I can see a collection of the permissions attached to the user with themanage own userspermission being part of it.Am I missing some important step that I need to take into consideration in order for my approach to work or does the package restrict the usage of only one type of model in the config?
Thanks for the great package!
Beta Was this translation helpful? Give feedback.
All reactions