Skip to content

A free open source IT asset/license management system

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

snipe45afe725a1f0
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());
+ }
+
}
}