From 45afe725a1f039dddd87537e16470963684f0711 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 9 Jul 2020 20:03:47 -0700 Subject: [PATCH] =?UTF-8?q?Only=20try=20to=20get=20the=20company=20if=20th?= =?UTF-8?q?ere=20is=20an=20auth=E2=80=99d=20user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (Needed for command line tools, where no Auth::user() is present) --- app/Models/Company.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Models/Company.php b/app/Models/Company.php index bb3467c38c..ea92f25952 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -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()); + } + } }