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,9 +128,12 @@ final class Company extends SnipeModel
} elseif (!static::isFullMultipleCompanySupportEnabled()) {
return true;
} else {
$current_user_company_id = Auth::user()->company_id;
$companyable_company_id = $companyable->company_id;
return ($current_user_company_id == null || $current_user_company_id == $companyable_company_id || Auth::user()->isSuperUser());
if (Auth::user()) {
$current_user_company_id = Auth::user()->company_id;
$companyable_company_id = $companyable->company_id;
return ($current_user_company_id == null || $current_user_company_id == $companyable_company_id || Auth::user()->isSuperUser());
}
}
}