WIP: Check if the share owner is still a valid user

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2019-08-27 16:31:29 +02:00
parent 9ac15bc4e9
commit 28313a94bc
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
3 changed files with 26 additions and 6 deletions

View File

@ -597,7 +597,11 @@ class DefaultShareProvider implements IShareProvider {
$cursor = $qb->execute();
$shares = [];
while ($data = $cursor->fetch()) {
$shares[$data['fileid']][] = $this->createShare($data);
try {
$shares[$data['fileid']][] = $this->createShare($data);
} catch (\InvalidArgumentException $e) {
// ignore exception and leave out share
}
}
$cursor->closeCursor();
@ -727,8 +731,11 @@ class DefaultShareProvider implements IShareProvider {
$shares = [];
while($data = $cursor->fetch()) {
$shares[] = $this->createShare($data);
}
try {
$shares[] = $this->createShare($data);
} catch (\InvalidArgumentException $e) {
// ignore exception and leave out share
} }
$cursor->closeCursor();
return $shares;
@ -799,7 +806,11 @@ class DefaultShareProvider implements IShareProvider {
while($data = $cursor->fetch()) {
if ($this->isAccessibleResult($data)) {
$shares[] = $this->createShare($data);
try {
$shares[] = $this->createShare($data);
} catch (\InvalidArgumentException $e) {
// ignore exception and leave out share
}
}
}
$cursor->closeCursor();
@ -864,7 +875,11 @@ class DefaultShareProvider implements IShareProvider {
}
if ($this->isAccessibleResult($data)) {
$shares2[] = $this->createShare($data);
try {
$shares2[] = $this->createShare($data);
} catch (\InvalidArgumentException $e) {
// ignore exception and leave out share
}
}
}
$cursor->closeCursor();

View File

@ -1173,6 +1173,9 @@ class Manager implements IManager {
} catch (ShareNotFound $e) {
unset($shares[$key]);
}
if (!$this->userManager->userExists($share->getShareOwner())) {
unset($shares[$key]);
}
}
return $shares;

View File

@ -396,7 +396,9 @@ class Share implements \OCP\Share\IShare {
if (!is_string($shareOwner)) {
throw new \InvalidArgumentException();
}
//TODO checks
if(!$this->userManager->userExists($this->shareOwner)) {
throw new \InvalidArgumentException('Share owner doesn\'t exist');
}
$this->shareOwner = $shareOwner;
return $this;