fix: Limit label actions to labels of the cards board
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
committed by
Julius Knorr
parent
aac11e96b5
commit
a92dc282a8
@@ -609,8 +609,9 @@ class CardService {
|
||||
public function assignLabel($cardId, $labelId) {
|
||||
$this->cardServiceValidator->check(compact('cardId', 'labelId'));
|
||||
|
||||
|
||||
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
|
||||
$this->permissionService->checkPermission($this->labelMapper, $labelId, Acl::PERMISSION_READ);
|
||||
|
||||
if ($this->boardService->isArchived($this->cardMapper, $cardId)) {
|
||||
throw new StatusException('Operation not allowed. This board is archived.');
|
||||
}
|
||||
@@ -619,6 +620,9 @@ class CardService {
|
||||
throw new StatusException('Operation not allowed. This card is archived.');
|
||||
}
|
||||
$label = $this->labelMapper->find($labelId);
|
||||
if ($label->getBoardId() !== $this->cardMapper->findBoardId($card->getId())) {
|
||||
throw new StatusException('Operation not allowed. Label does not exist.');
|
||||
}
|
||||
$this->cardMapper->assignLabel($cardId, $labelId);
|
||||
$this->changeHelper->cardChanged($cardId);
|
||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_LABEL_ASSIGN, ['label' => $label]);
|
||||
@@ -640,6 +644,8 @@ class CardService {
|
||||
|
||||
|
||||
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
|
||||
$this->permissionService->checkPermission($this->labelMapper, $labelId, Acl::PERMISSION_READ);
|
||||
|
||||
if ($this->boardService->isArchived($this->cardMapper, $cardId)) {
|
||||
throw new StatusException('Operation not allowed. This board is archived.');
|
||||
}
|
||||
@@ -648,6 +654,9 @@ class CardService {
|
||||
throw new StatusException('Operation not allowed. This card is archived.');
|
||||
}
|
||||
$label = $this->labelMapper->find($labelId);
|
||||
if ($label->getBoardId() !== $this->cardMapper->findBoardId($card->getId())) {
|
||||
throw new StatusException('Operation not allowed. Label does not exist.');
|
||||
}
|
||||
$this->cardMapper->removeLabel($cardId, $labelId);
|
||||
$this->changeHelper->cardChanged($cardId);
|
||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_LABEL_UNASSING, ['label' => $label]);
|
||||
|
||||
Reference in New Issue
Block a user