File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77use App \Helpers \MetaFormats \Validators \VMixed ;
88use App \Helpers \MetaFormats \Validators \VString ;
99use App \Helpers \MetaFormats \Validators \VUuid ;
10+ use App \Exceptions \BadRequestException ;
1011use App \Exceptions \ForbiddenRequestException ;
1112use App \Exceptions \InvalidApiArgumentException ;
1213use App \Exceptions \NotFoundException ;
@@ -330,6 +331,10 @@ public function actionGetAttachmentFiles(string $id)
330331 public function checkDeleteAttachmentFile (string $ id , string $ fileId )
331332 {
332333 $ exercise = $ this ->exercises ->findOrThrow ($ id );
334+ $ file = $ this ->attachmentFiles ->findOrThrow ($ fileId );
335+ if (!$ file ->getExercises ()->contains ($ exercise )) {
336+ throw new BadRequestException ("Selected file is not an attachment file for given exercise. " );
337+ }
333338 if (!$ this ->exerciseAcl ->canUpdate ($ exercise )) {
334339 throw new ForbiddenRequestException ("You cannot delete attachment files for this exercise. " );
335340 }
You can’t perform that action at this time.
0 commit comments