Skip to content

Commit 2dbbee2

Browse files
committed
fix(api): Make sure user has permissions to update access fields
Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent cf84d13 commit 2dbbee2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/Controller/ApiController.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,17 @@ public function updateForm(int $formId, array $keyValuePairs): DataResponse {
278278
throw new OCSForbiddenException();
279279
}
280280

281+
// Do not allow changing showToAllUsers if disabled
282+
if (isset($keyValuePairs['access'])) {
283+
$showAll = $keyValuePairs['access']['showToAllUsers'] ?? false;
284+
$permitAll = $keyValuePairs['access']['permitAllUsers'] ?? false;
285+
if (($showAll && !$this->configService->getAllowShowToAll())
286+
|| ($permitAll && !$this->configService->getAllowPermitAll())) {
287+
$this->logger->info('Not allowed to update showToAllUsers or permitAllUsers');
288+
throw new OCSForbiddenException();
289+
}
290+
}
291+
281292
// Process file linking
282293
if (isset($keyValuePairs['path']) && isset($keyValuePairs['fileFormat'])) {
283294
$file = $this->submissionService->writeFileToCloud($form, $keyValuePairs['path'], $keyValuePairs['fileFormat']);

0 commit comments

Comments
 (0)