mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 14:23:17 -04:00
Merge pull request #44362 from nextcloud/artonge/feat/check_permissions_of_all_nodes_for_versions
Check permissions of all accessible file for versions
This commit is contained in:
commit
ddb84f9738
1 changed files with 14 additions and 6 deletions
|
|
@ -275,15 +275,23 @@ class LegacyVersionsBackend implements IVersionBackend, IDeletableVersionBackend
|
|||
throw new NotFoundException("No user logged in");
|
||||
}
|
||||
|
||||
if ($sourceFile->getOwner()?->getUID() !== $currentUserId) {
|
||||
$nodes = $this->rootFolder->getUserFolder($currentUserId)->getById($sourceFile->getId());
|
||||
$sourceFile = array_pop($nodes);
|
||||
if (!$sourceFile) {
|
||||
throw new NotFoundException("Version file not accessible by current user");
|
||||
if ($sourceFile->getOwner()?->getUID() === $currentUserId) {
|
||||
return ($sourceFile->getPermissions() & $permissions) === $permissions;
|
||||
}
|
||||
|
||||
$nodes = $this->rootFolder->getUserFolder($currentUserId)->getById($sourceFile->getId());
|
||||
|
||||
if (count($nodes) === 0) {
|
||||
throw new NotFoundException("Version file not accessible by current user");
|
||||
}
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
if (($node->getPermissions() & $permissions) === $permissions) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return ($sourceFile->getPermissions() & $permissions) === $permissions;
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setMetadataValue(Node $node, int $revision, string $key, string $value): void {
|
||||
|
|
|
|||
Loading…
Reference in a new issue