aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-08-03 16:13:38 +0200
committerCôme Chilliet <91878298+come-nc@users.noreply.github.com>2023-08-28 09:40:12 +0200
commit8c9aa9a91962afe32e50c594dbc67352a963e4cd (patch)
tree5f15b51685fa147293440d2d354d7d4ffa5fe379
parentce9e0aec7f9c56b95ccddaea316f00f936d3ad3b (diff)
downloadnextcloud-server-8c9aa9a91962afe32e50c594dbc67352a963e4cd.tar.gz
nextcloud-server-8c9aa9a91962afe32e50c594dbc67352a963e4cd.zip
Set files_sharing:hide_disabled_user_shares to 'yes' to hide shares from disabled users
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r--lib/private/Share20/Manager.php24
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 9360046bc24..2e6b9ab840c 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -1343,7 +1343,7 @@ class Manager implements IManager {
$added = 0;
foreach ($shares as $share) {
try {
- $this->checkExpireDate($share);
+ $this->checkShare($share);
} catch (ShareNotFound $e) {
//Ignore since this basically means the share is deleted
continue;
@@ -1402,7 +1402,7 @@ class Manager implements IManager {
// remove all shares which are already expired
foreach ($shares as $key => $share) {
try {
- $this->checkExpireDate($share);
+ $this->checkShare($share);
} catch (ShareNotFound $e) {
unset($shares[$key]);
}
@@ -1448,7 +1448,7 @@ class Manager implements IManager {
$share = $provider->getShareById($id, $recipient);
- $this->checkExpireDate($share);
+ $this->checkShare($share);
return $share;
}
@@ -1532,7 +1532,7 @@ class Manager implements IManager {
throw new ShareNotFound($this->l->t('The requested share does not exist anymore'));
}
- $this->checkExpireDate($share);
+ $this->checkShare($share);
/*
* Reduce the permissions for link or email shares if public upload is not enabled
@@ -1545,11 +1545,25 @@ class Manager implements IManager {
return $share;
}
- protected function checkExpireDate($share) {
+ /**
+ * Check expire date and disabled owner
+ *
+ * @throws ShareNotFound
+ */
+ protected function checkShare(IShare $share): void {
if ($share->isExpired()) {
$this->deleteShare($share);
throw new ShareNotFound($this->l->t('The requested share does not exist anymore'));
}
+ if ($this->config->getAppValue('files_sharing', 'hide_disabled_user_shares', 'no') === 'yes') {
+ $uids = array_unique([$share->getShareOwner(),$share->getSharedBy()]);
+ foreach ($uids as $uid) {
+ $user = $this->userManager->get($uid);
+ if (($user !== null) && !$user->isEnabled()) {
+ throw new ShareNotFound($this->l->t('The requested share comes from a disabled user'));
+ }
+ }
+ }
}
/**