]> _ Git - cubedesigners_userdatabase.git/commitdiff
wip #3753
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 9 Dec 2020 07:05:00 +0000 (08:05 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 9 Dec 2020 07:05:00 +0000 (08:05 +0100)
src/Company.php
src/User.php

index eb31ae30f712b88179a6d1493469bb4cc684cc44..b41c14684884ba3bd788f2f6c26a8fa7eaeab8a7 100644 (file)
@@ -86,10 +86,15 @@ class Company extends CubistMagicAbstractModel
 
     public static function addOwnerClause(Builder $builder)
     {
-        if(backpack_user()->hasPermissionTo('company:admin')){
+        $bu = backpack_user();
+        if (null === $bu) {
+            $builder->where('id', '<', '0');
             return;
         }
-        $builder->whereIn('id', Permissions::getManagedCompanies(backpack_user()->id));
+        if ($bu->hasPermissionTo('company:admin')){
+            return;
+        }
+        $builder->whereIn('id', Permissions::getManagedCompanies($bu->id));
     }
 
 }
index 402de80fbe5152b48e10b13bf9adb173a9e6462f..52894af07e4645f46a7e2979187a793abe220358 100644 (file)
@@ -153,7 +153,7 @@ class User extends CubistMagicAuthenticatable
         if ($bu->hasPermissionTo('users:admin')) {
             return;
         }
-        $builder->whereIn('id', Permissions::getManagedUsers(backpack_user()->id));
+        $builder->whereIn('id', Permissions::getManagedUsers($bu->id));
     }