diff --git a/src/OrderController.php b/src/OrderController.php index 212b43a..05a60c3 100644 --- a/src/OrderController.php +++ b/src/OrderController.php @@ -25,7 +25,7 @@ class OrderController $model = app('media-library-helpers')->get($parentModel); $model = $model::find($parentId); - $this->authorize('updateMedia', [$model, $collectionName]); + $this->authorize('listMedia', [$model, $collectionName]); Media::setNewOrder($request->order); diff --git a/tests/Feature/ReorderTest.php b/tests/Feature/ReorderTest.php index e1153fb..4338563 100644 --- a/tests/Feature/ReorderTest.php +++ b/tests/Feature/ReorderTest.php @@ -38,3 +38,16 @@ test('images should belong to same model', function () { $response->assertJsonValidationErrors('order'); }); + +test('it should authorize', function () { + $this->auth(['listMedia' => false])->registerModel(); + + $post = $this->newPost(); + $media = $post->addMedia($this->pdfFile()->getPathname())->preservingOriginal()->toMediaCollection('images'); + + $response = $this->patchJson("/mediaupload/post/{$post->id}/images", [ + 'order' => [$media->id], + ]); + + $response->assertStatus(403); +});