@@ -600,8 +600,9 @@ public function undone(int $id): Card {
600600 public function assignLabel ($ cardId , $ labelId ) {
601601 $ this ->cardServiceValidator ->check (compact ('cardId ' , 'labelId ' ));
602602
603-
604603 $ this ->permissionService ->checkPermission ($ this ->cardMapper , $ cardId , Acl::PERMISSION_EDIT );
604+ $ this ->permissionService ->checkPermission ($ this ->labelMapper , $ labelId , Acl::PERMISSION_READ );
605+
605606 if ($ this ->boardService ->isArchived ($ this ->cardMapper , $ cardId )) {
606607 throw new StatusException ('Operation not allowed. This board is archived. ' );
607608 }
@@ -610,6 +611,9 @@ public function assignLabel($cardId, $labelId) {
610611 throw new StatusException ('Operation not allowed. This card is archived. ' );
611612 }
612613 $ label = $ this ->labelMapper ->find ($ labelId );
614+ if ($ label ->getBoardId () !== $ this ->cardMapper ->findBoardId ($ card ->getId ())) {
615+ throw new StatusException ('Operation not allowed. Label does not exist. ' );
616+ }
613617 $ this ->cardMapper ->assignLabel ($ cardId , $ labelId );
614618 $ this ->changeHelper ->cardChanged ($ cardId );
615619 $ this ->activityManager ->triggerEvent (ActivityManager::DECK_OBJECT_CARD , $ card , ActivityManager::SUBJECT_LABEL_ASSIGN , ['label ' => $ label ]);
@@ -631,6 +635,8 @@ public function removeLabel($cardId, $labelId) {
631635
632636
633637 $ this ->permissionService ->checkPermission ($ this ->cardMapper , $ cardId , Acl::PERMISSION_EDIT );
638+ $ this ->permissionService ->checkPermission ($ this ->labelMapper , $ labelId , Acl::PERMISSION_READ );
639+
634640 if ($ this ->boardService ->isArchived ($ this ->cardMapper , $ cardId )) {
635641 throw new StatusException ('Operation not allowed. This board is archived. ' );
636642 }
@@ -639,6 +645,9 @@ public function removeLabel($cardId, $labelId) {
639645 throw new StatusException ('Operation not allowed. This card is archived. ' );
640646 }
641647 $ label = $ this ->labelMapper ->find ($ labelId );
648+ if ($ label ->getBoardId () !== $ this ->cardMapper ->findBoardId ($ card ->getId ())) {
649+ throw new StatusException ('Operation not allowed. Label does not exist. ' );
650+ }
642651 $ this ->cardMapper ->removeLabel ($ cardId , $ labelId );
643652 $ this ->changeHelper ->cardChanged ($ cardId );
644653 $ this ->activityManager ->triggerEvent (ActivityManager::DECK_OBJECT_CARD , $ card , ActivityManager::SUBJECT_LABEL_UNASSING , ['label ' => $ label ]);
0 commit comments