diff --git a/application/Espo/Core/Console/Commands/AclCheck.php b/application/Espo/Core/Console/Commands/AclCheck.php index 7ef91cad42..91fd26f39e 100644 --- a/application/Espo/Core/Console/Commands/AclCheck.php +++ b/application/Espo/Core/Console/Commands/AclCheck.php @@ -37,41 +37,51 @@ class AclCheck extends Base $scope = $options['scope'] ?? null; $id = $options['id'] ?? null; $action = $options['action'] ?? null; - $portalId = $options['portalId'] ?? null; if (empty($userId)) return; if (empty($scope)) return; if (empty($id)) return; $container = $this->getContainer(); - - if ($portalId) { - $application = new \Espo\Core\Portal\Application($portalId); - $container = $application->getContainer(); - } - $entityManager = $container->get('entityManager'); $user = $entityManager->getEntity('User', $userId); if (!$user) return; - if ($portalId) { - if ( - !$user->isPortal() - || - !in_array($portalId, $user->getLinkMultipleIdList('portals')) - ) { - return; + if ($user->isPortal()) { + $portalIdList = $user->getLinkMultipleIdList('portals'); + foreach ($portalIdList as $portalId) { + $application = new \Espo\Core\Portal\Application($portalId); + $containerPortal = $application->getContainer(); + $entityManager = $containerPortal->get('entityManager'); + + $user = $entityManager->getEntity('User', $userId); + if (!$user) return; + + $result = $this->check($user, $scope, $id, $action, $containerPortal); + if ($result) { + return 'true'; + } } + return; } + if ($this->check($user, $scope, $id, $action, $container)) { + return 'true'; + } + } + + protected function check($user, $scope, $id, $action, $container) + { + $entityManager = $container->get('entityManager'); + $entity = $entityManager->getEntity($scope, $id); if (!$entity) return; $aclManager = $container->get('aclManager'); if ($aclManager->check($user, $entity, $action)) { - return 'true'; + return true; } } } diff --git a/application/Espo/Core/WebSocket/Pusher.php b/application/Espo/Core/WebSocket/Pusher.php index 0a199e20c5..9b135794c0 100644 --- a/application/Espo/Core/WebSocket/Pusher.php +++ b/application/Espo/Core/WebSocket/Pusher.php @@ -80,7 +80,7 @@ class Pusher implements WampServerInterface if ($checkCommand) { $checkResult = shell_exec($checkCommand); if ($checkResult !== 'true') { - if ($this->isDebugMode) echo "check access faied for topic {$topicId} for user {$userId}\n"; + if ($this->isDebugMode) echo "check access failed for topic {$topicId} for user {$userId}\n"; return; } } @@ -309,14 +309,16 @@ class Pusher implements WampServerInterface $connection->event($topicId, $data); } } + + if ($this->isDebugMode) echo "onMessage {$topicId} for {$userId}\n"; } else { $topic = $this->topicHash[$topicId] ?? null; if ($topic) { $topic->broadcast($data); if ($this->isDebugMode) echo "send {$topicId} to all\n"; } - } - if ($this->isDebugMode) echo "onMessage {$topicId} for {$userId}\n"; + if ($this->isDebugMode) echo "onMessage {$topicId} for all\n"; + } } } diff --git a/application/Espo/Resources/metadata/app/webSocket.json b/application/Espo/Resources/metadata/app/webSocket.json index cfa455fffa..ef70dc32e9 100644 --- a/application/Espo/Resources/metadata/app/webSocket.json +++ b/application/Espo/Resources/metadata/app/webSocket.json @@ -2,8 +2,8 @@ "categories": { "newNotification": {}, "streamUpdate": { - "paramList": ["scope", "id", "portalId"], - "accessCheckCommand": "AclCheck --userId=:userId --scope=:scope --id=:id --action=stream --portalId=:portalId" + "paramList": ["scope", "id"], + "accessCheckCommand": "AclCheck --userId=:userId --scope=:scope --id=:id --action=stream" } } } diff --git a/client/src/views/stream/panel.js b/client/src/views/stream/panel.js index 52a0a4e9c3..df91e9745e 100644 --- a/client/src/views/stream/panel.js +++ b/client/src/views/stream/panel.js @@ -190,9 +190,6 @@ Espo.define('views/stream/panel', ['views/record/panels/relationship', 'lib!Text if (!this.getConfig().get('useWebSocket')) return; var topic = 'streamUpdate.' + this.model.entityType + '.' + this.model.id; - if (this.getUser().isPortal()) { - topic += '.' + this.getUser().get('portalId'); - } this.streamUpdateWebSocketTopic = topic; this.isSubscribedToWebSocked = true;