![]() |
I'm using the following spark command to create three default users for testing purposes:
PHP Code: <?php PHP Code: print_r(auth()->user()->getPermissions()); Same issue as described in this post.
Permissions vary by Groups.
Your command creates the user with the desired group. Therefore, you can use the following command to access the user group. PHP Code: print_r(auth()->user()->getGroups()); If you want to access permissions, you must first add permissions for each user. In this command, you have not added permission for the user, so an empty array is returned. see https://codeigniter4.github.io/shield/au...permission
It's my understanding that the AuthGroups configuration file provides a default set of permissions for the groups under the matrix property. So shouldn't those permissions be returned?
Using matrix is useful for checking access permissions with method can().
So if the user is in group superadmin and the permission is not registered in table auth_permissions_users for it. And you have AuthGroups.php settings as follows. PHP Code: You will get output yes. Even though the user is not registered for permissions(admin.access). PHP Code: At least that's my impression. And I don't know anything more than that. Quote:getPermissions() That is, getPermissions() returns only user-level permissions. The $matrix defines group-level permissions.
I sent a PR to improve the docs:
https://github.com/codeigniter4/shield/pull/714 |
Welcome Guest, Not a member yet? Register Sign In |