Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit c9902ef

Browse files
committed
Add more check on user before modifying a share.
1 parent 1744010 commit c9902ef

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

core/src/plugins/action.share/class.ShareCenter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,9 @@ public function createSharedMinisite($httpVars, $repository, $accessDriver)
15701570
$this->initPublicFolder($downloadFolder);
15711571

15721572
if(isset($existingData)){
1573+
$repo = ConfService::getRepositoryById($existingData["REPOSITORY"]);
1574+
if($repo == null) throw new Exception("Oups, something went wrong");
1575+
$this->shareStore->testUserCanEditShare($repo->getOwner());
15731576
$data = $existingData;
15741577
}else{
15751578
$data = array(
@@ -1825,6 +1828,7 @@ public function createSharedRepository($httpVars, $repository, $accessDriver, $u
18251828
$options["PLUGINS_DATA"] = $customData;
18261829
}
18271830
if (isSet($editingRepo)) {
1831+
$this->shareStore->testUserCanEditShare($editingRepo->getOwner());
18281832
$newRepo = $editingRepo;
18291833
$replace = false;
18301834
if ($editingRepo->getDisplay() != $label) {

core/src/plugins/action.share/class.ShareStore.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public function listShares($limitToUser = '', $parentRepository = '', $cursor =
278278
return $dbLets;
279279
}
280280

281-
protected function testUserCanEditShare($userId){
281+
public function testUserCanEditShare($userId){
282282

283283
if(empty($userId)){
284284
$mess = ConfService::getMessages();
@@ -432,7 +432,12 @@ public function incrementDownloadCounter($hash){
432432

433433
public function resetDownloadCounter($hash, $userId){
434434
$data = $this->loadShare($hash);
435-
// TODO We must check that the user has the right to do that!
435+
$repoId = $data["REPOSITORY"];
436+
$repo = ConfService::getRepositoryById($repoId);
437+
if ($repo == null) {
438+
throw new Exception("Cannot find associated share");
439+
}
440+
$this->testUserCanEditShare($repo->getOwner());
436441
PublicletCounter::reset($hash);
437442
}
438443

0 commit comments

Comments
 (0)