Skip to content

Commit 1e71d3c

Browse files
committed
feat: make sure user has file_create permission and save policy on source when downloading an image
Resolves #41
1 parent a2d5cbb commit 1e71d3c

File tree

1 file changed

+8
-0
lines changed
  • core/components/modai/src/API/Download

1 file changed

+8
-0
lines changed

core/components/modai/src/API/Download/Image.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ public function post(ServerRequestInterface $request): void
2020
throw APIException::unauthorized();
2121
}
2222

23+
if (!$this->modx->hasPermission('file_create')) {
24+
throw APIException::unauthorized();
25+
}
26+
2327
$data = $request->getParsedBody();
2428

2529
$url = $this->modx->getOption('url', $data);
@@ -79,6 +83,10 @@ public function post(ServerRequestInterface $request): void
7983
throw new LexiconException('modai.error.source_init failed');
8084
}
8185

86+
if (!$source->checkPolicy('create')) {
87+
throw APIException::unauthorized();
88+
}
89+
8290
$path = Settings::getImageSetting($this->modx, $field, 'path');
8391
$filePath = $this->createFilePath($path, $resource);
8492

0 commit comments

Comments
 (0)