Skip to content
Snippets Groups Projects
Commit f2dd56af authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms Committed by David Siegfried
Browse files

fixes #4277

Closes #4277

Merge request !3116
parent 0850b4ce
No related branches found
No related tags found
No related merge requests found
...@@ -19,20 +19,31 @@ class SubfoldersIndex extends JsonApiController ...@@ -19,20 +19,31 @@ class SubfoldersIndex extends JsonApiController
*/ */
public function __invoke(Request $request, Response $response, $args) public function __invoke(Request $request, Response $response, $args)
{ {
if (!$folder = \FileManager::getTypedFolder($args['id'])) { $folder = \FileManager::getTypedFolder($args['id']);
if (!$folder) {
throw new RecordNotFoundException(); throw new RecordNotFoundException();
} }
if (!Authority::canShowFolder($this->getUser($request), $folder)) { $user = $this->getUser($request);
if (!Authority::canShowFolder($user, $folder)) {
throw new AuthorizationFailedException(); throw new AuthorizationFailedException();
} }
$subfolders = array_map( $subfolders = array_reduce(
function ($subfolder) { $folder->subfolders->getArrayCopy(),
return $subfolder->getTypedFolder(); function ($result, $subfolder) use ($user) {
$folder = $subfolder->getTypedFolder();
if (Authority::canShowFolder($user, $folder)) {
$result[] = $folder;
}
return $result;
}, },
$folder->subfolders->getArrayCopy() []
); );
list($offset, $limit) = $this->getOffsetAndLimit(); list($offset, $limit) = $this->getOffsetAndLimit();
return $this->getPaginatedContentResponse( return $this->getPaginatedContentResponse(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment