]> _ Git - cubedesigners_userdatabase.git/commitdiff
wait #6198 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 17 Aug 2023 12:53:51 +0000 (14:53 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 17 Aug 2023 12:53:51 +0000 (14:53 +0200)
src/app/Models/User.php

index ec0c020b708c6684bc6b4b6434f6761598df24c1..e9ea5b4c018f3040cd62b4be2f525395c2c64e04 100644 (file)
@@ -180,6 +180,7 @@ class User extends CubistMagicAuthenticatable implements HasLocalePreference
             return $this->companyName;
         }
         $company = $this->companyName;
+
         if (mb_strlen($company) > 30) {
             $company = '<span title="' . $company . '">' . mb_substr($company, 0, 27) . '...</span>';
         }
@@ -272,17 +273,23 @@ class User extends CubistMagicAuthenticatable implements HasLocalePreference
 
     public function isOwner($user)
     {
+        if ($user instanceof User) {
+            $company = $user->company;
+            $user = $user->id;
+        } else {
+            $company = Permissions::getCompanyByUser($user);
+        }
         if (null === $this->id) {
             return true;
         }
         if (null === $user) {
             return false;
         }
-        if ($user->company == 7 && !$this->can('loginascube')) {
+        if ($company == 7 && !$this->can('loginascube')) {
             return false;
         }
         /** @var $user self */
-        return in_array($user->id, $this->getManagedUsers());
+        return in_array($user, $this->getManagedUsers());
     }
 
     public static function addOwnerClause(Builder $builder)