Fixed tests

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-04-17 09:26:07 +01:00
parent c604f08749
commit ab3b5ca4ef
2 changed files with 11 additions and 1 deletions

View file

@ -131,7 +131,7 @@ final class Company extends SnipeModel
public static function isCurrentUserHasAccess($companyable)
{
// When would this even happen tho??
if (is_null($companyable)) {
if (!$companyable) {
return false;
}

View file

@ -52,6 +52,16 @@ abstract class SnipePermissionsPolicy
return true;
}
/**
* If we got here by $this→authorize('something', $actualModel) then we can continue on Il but if we got here
* via $this→authorize('something', Model::class) then calling Company:: isCurrentUserHasAccess($item) gets weird.
* Bail out here by returning "nothing" and allow the relevant method lower in this class to be called and handle authorization.
*/
if (!$item instanceof Model){
return;
}
/**
* The Company::isCurrentUserHasAccess() method from the company model handles the check for FMCS already so we
* don't have to do that here.