diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 85727ad4857e7..91b68f477197b 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -717,6 +717,10 @@ public function createShare( if ($shareWith === null || !$this->userManager->userExists($shareWith)) { throw new OCSNotFoundException($this->l->t('Please specify a valid account to share with')); } + $shareWithUser = $this->userManager->get($shareWith); + if ($shareWithUser !== null && !$shareWithUser->isEnabled()) { + throw new OCSForbiddenException($this->l->t('Cannot share with a disabled account.')); + } $share->setSharedWith($shareWith); $share->setPermissions($permissions); } elseif ($shareType === IShare::TYPE_GROUP) { diff --git a/lib/private/Collaboration/Collaborators/MailPlugin.php b/lib/private/Collaboration/Collaborators/MailPlugin.php index 1e08aff726b11..3cd58a3d51a84 100644 --- a/lib/private/Collaboration/Collaborators/MailPlugin.php +++ b/lib/private/Collaboration/Collaborators/MailPlugin.php @@ -126,7 +126,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult): b if (isset($contact['isLocalSystemBook'])) { $contactUser = $this->userManager->get($contact['UID']); - if ($contactUser === null) { + if ($contactUser === null || !$contactUser->isEnabled()) { continue; } diff --git a/lib/private/Collaboration/Collaborators/RemotePlugin.php b/lib/private/Collaboration/Collaborators/RemotePlugin.php index e52683cfd5a04..ce6072ad92e54 100644 --- a/lib/private/Collaboration/Collaborators/RemotePlugin.php +++ b/lib/private/Collaboration/Collaborators/RemotePlugin.php @@ -72,7 +72,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult): b } $localUser = $this->userManager->get($remoteUser); - if ($localUser !== null && $remoteUser !== $this->userId && $cloudId === $localUser->getCloudId()) { + if ($localUser !== null && $localUser->isEnabled() && $remoteUser !== $this->userId && $cloudId === $localUser->getCloudId()) { $result['wide'][] = [ 'label' => $contact['FN'], 'uuid' => $contact['UID'], diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php index 78d728179eccd..ad338a9416363 100644 --- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php @@ -56,6 +56,9 @@ protected function setUp(): void { $user ->method('getUID') ->willReturn($uid); + $user + ->method('isEnabled') + ->willReturn(!str_starts_with($uid, 'disabled')); return $user; });