Skip to content

Commit 3636433

Browse files
Merge pull request #62153 from nextcloud/backport/62092/stable31
[stable31] fix(files_sharing): Allow access to shares by disabled users if hide_disabled_user_shares is enabled
2 parents 17b4256 + ed7214d commit 3636433

3 files changed

Lines changed: 3 additions & 15 deletions

File tree

apps/files_sharing/lib/Controller/ShareController.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -273,18 +273,6 @@ protected function emitShareAccessEvent(IShare $share, string $step = '', int $e
273273
* @return bool
274274
*/
275275
private function validateShare(IShare $share) {
276-
// If the owner is disabled no access to the link is granted
277-
$owner = $this->userManager->get($share->getShareOwner());
278-
if ($owner === null || !$owner->isEnabled()) {
279-
return false;
280-
}
281-
282-
// If the initiator of the share is disabled no access is granted
283-
$initiator = $this->userManager->get($share->getSharedBy());
284-
if ($initiator === null || !$initiator->isEnabled()) {
285-
return false;
286-
}
287-
288276
return $share->getNode()->isReadable() && $share->getNode()->isShareable();
289277
}
290278

lib/private/Share20/Manager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,8 +1490,8 @@ private function checkShare(IShare $share, int &$added = 1): void {
14901490
$added--;
14911491
throw new ShareNotFound($this->l->t('The requested share does not exist anymore'));
14921492
}
1493-
if ($this->config->getAppValue('files_sharing', 'hide_disabled_user_shares', 'no') === 'yes') {
1494-
$uids = array_unique([$share->getShareOwner(),$share->getSharedBy()]);
1493+
if ($this->config->getAppValue('files_sharing', 'hide_disabled_user_shares', 'yes') === 'yes') {
1494+
$uids = array_unique([$share->getShareOwner(), $share->getSharedBy()]);
14951495
foreach ($uids as $uid) {
14961496
$user = $this->userManager->get($uid);
14971497
if ($user?->isEnabled() === false) {

tests/lib/Share20/ManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3140,7 +3140,7 @@ public function testGetShareByTokenHideDisabledUser(): void {
31403140
->method('getAppValue')
31413141
->willReturnMap([
31423142
['core', 'shareapi_allow_links', 'yes', 'yes'],
3143-
['files_sharing', 'hide_disabled_user_shares', 'no', 'yes'],
3143+
['files_sharing', 'hide_disabled_user_shares', 'yes', 'yes'],
31443144
]);
31453145

31463146
$this->l->expects($this->once())

0 commit comments

Comments
 (0)