Skip to content

Commit

Permalink
Properly check for the stack AND setting board permissions
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Apr 11, 2022
1 parent 0ce4279 commit 86d3de2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/Service/StackService.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,13 @@ public function update($id, $title, $boardId, $order, $deletedAt) {
throw new BadRequestException('order must be a number');
}

$this->permissionService->checkPermission($this->stackMapper, $boardId, Acl::PERMISSION_MANAGE);
if ($this->boardService->isArchived($this->stackMapper, $boardId)) {
$this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_MANAGE);
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_MANAGE);

if ($this->boardService->isArchived($this->stackMapper, $id)) {
throw new StatusException('Operation not allowed. This board is archived.');
}

$stack = $this->stackMapper->find($id);
$changes = new ChangeSet($stack);
$stack->setTitle($title);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Service/StackServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function testDelete() {
}

public function testUpdate() {
$this->permissionService->expects($this->once())->method('checkPermission');
$this->permissionService->expects($this->exactly(2))->method('checkPermission');
$stack = new Stack();
$this->stackMapper->expects($this->once())->method('find')->willReturn($stack);
$this->stackMapper->expects($this->once())->method('update')->willReturn($stack);
Expand Down

0 comments on commit 86d3de2

Please sign in to comment.