psecio / gatekeeper

Gatekeeper: An Authentication & Authorization Library
366 stars 23 forks source link

hasPermission() function always return false #62

Open SamuelY opened 8 years ago

SamuelY commented 8 years ago

I find that hasPermission() have wrong in UserModel.php.

the function return ($perm->id !== null && $perm->id === $permId) ? true : false; should be modified as return ($perm->id !== null && $perm->permissionId === $permId) ? true : false;

I have a suggestion

hasPermission() return true only if the requested permission isn't expired

please check it

gdespaux commented 8 years ago

I also had this issue. I'm not positive, but I believe the === may be the issue. Perhaps one of the id's is returned as an integer, and the other as a string? Changing to == allows it to function as expected.

marksparrish commented 8 years ago

I agree with @SamuelY. I think the issue stems from $perm being pulled from the user_permission table. $perm->id is the id from that table and not the id from the permissions table. However if you change it as suggested you get the correct id.