Skip to content

Commit f9e0471

Browse files
authored
Merge pull request #66848 from nextcloud/backport/66403/stable33
[stable33] fix: Don't auto complete nor allow sharing to disabled users
2 parents fe5cbcf + bc91831 commit f9e0471

4 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎apps/files_sharing/lib/Controller/ShareAPIController.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,10 @@ public function createShare(
717717
if ($shareWith === null || !$this->userManager->userExists($shareWith)) {
718718
throw new OCSNotFoundException($this->l->t('Please specify a valid account to share with'));
719719
}
720+
$shareWithUser = $this->userManager->get($shareWith);
721+
if ($shareWithUser !== null && !$shareWithUser->isEnabled()) {
722+
throw new OCSForbiddenException($this->l->t('Cannot share with a disabled account.'));
723+
}
720724
$share->setSharedWith($shareWith);
721725
$share->setPermissions($permissions);
722726
} elseif ($shareType === IShare::TYPE_GROUP) {

‎lib/private/Collaboration/Collaborators/MailPlugin.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult): b
126126

127127
if (isset($contact['isLocalSystemBook'])) {
128128
$contactUser = $this->userManager->get($contact['UID']);
129-
if ($contactUser === null) {
129+
if ($contactUser === null || !$contactUser->isEnabled()) {
130130
continue;
131131
}
132132

‎lib/private/Collaboration/Collaborators/RemotePlugin.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult): b
7272
}
7373

7474
$localUser = $this->userManager->get($remoteUser);
75-
if ($localUser !== null && $remoteUser !== $this->userId && $cloudId === $localUser->getCloudId()) {
75+
if ($localUser !== null && $localUser->isEnabled() && $remoteUser !== $this->userId && $cloudId === $localUser->getCloudId()) {
7676
$result['wide'][] = [
7777
'label' => $contact['FN'],
7878
'uuid' => $contact['UID'],

‎tests/lib/Collaboration/Collaborators/MailPluginTest.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ protected function setUp(): void {
5656
$user
5757
->method('getUID')
5858
->willReturn($uid);
59+
$user
60+
->method('isEnabled')
61+
->willReturn(!str_starts_with($uid, 'disabled'));
5962

6063
return $user;
6164
});

0 commit comments

Comments
 (0)