Only try to get the company if there is an auth’d user

(Needed for command line tools, where no Auth::user() is present)
This commit is contained in:
snipe 2020-07-09 20:03:47 -07:00
parent ec6ed256fb
commit 45afe725a1
No known key found for this signature in database
GPG key ID: 10BFFDA3ED34B5AC

View file

@ -128,10 +128,13 @@ final class Company extends SnipeModel
} elseif (!static::isFullMultipleCompanySupportEnabled()) { } elseif (!static::isFullMultipleCompanySupportEnabled()) {
return true; return true;
} else { } else {
if (Auth::user()) {
$current_user_company_id = Auth::user()->company_id; $current_user_company_id = Auth::user()->company_id;
$companyable_company_id = $companyable->company_id; $companyable_company_id = $companyable->company_id;
return ($current_user_company_id == null || $current_user_company_id == $companyable_company_id || Auth::user()->isSuperUser()); return ($current_user_company_id == null || $current_user_company_id == $companyable_company_id || Auth::user()->isSuperUser());
} }
}
} }
public static function isCurrentUserAuthorized() public static function isCurrentUserAuthorized()