Closed sclubricants closed 2 years ago
It's a little hard for me to look at all the code on mobile but if I understand what you are saying then: yes, you are correct that this is erroneously loading group permissions twice. Feel free to send over a PR with your change!
I have an issue where I'm calling has_permission(int) in my application in several places. If the user does not have the permission then the database gets called every time I call has_permission(int);
In Myth\Auth\Authorization\PermissionModel:doesUserHavePermission()
$this->getPermissionsForUser($userId) gets permissions for user - both group permissions and individual permissions. If the requested permission is found in all of the users permissions then return true.
For reference:
It would seem logical that if the requested permission is not found in this manner then the user does not have the permission and then return false.
However for some reason the code continues and looks up group permissions for the user once again. This seems redundant unless I'm missing something. If the user doesn't have the permission requested then it will continually lookup in the database.
It seems to me that the entire method doesUserHavePermission() should look like this:
Am I right or am I missing something?