mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-03 16:23:35 +08:00
Fixed related permissions query not considering drafts
Page-related items added on drafts could be visible in certain scenarios since the applied permissions query filters would not consider page draft visibility. This commit alters queries on related items to apply such filtering. Included test to cover API scenario. Thanks to @haxatron for reporting.
This commit is contained in:
@ -224,6 +224,29 @@ class AttachmentsApiTest extends TestCase
|
||||
unlink(storage_path($attachment->path));
|
||||
}
|
||||
|
||||
public function test_attachment_not_visible_on_other_users_draft()
|
||||
{
|
||||
$this->actingAsApiAdmin();
|
||||
$editor = $this->getEditor();
|
||||
|
||||
/** @var Page $page */
|
||||
$page = Page::query()->first();
|
||||
$page->draft = true;
|
||||
$page->owned_by = $editor;
|
||||
$page->save();
|
||||
$this->regenEntityPermissions($page);
|
||||
|
||||
$attachment = $this->createAttachmentForPage($page, [
|
||||
'name' => 'my attachment',
|
||||
'path' => 'https://example.com',
|
||||
'order' => 1,
|
||||
]);
|
||||
|
||||
$resp = $this->getJson("{$this->baseEndpoint}/{$attachment->id}");
|
||||
|
||||
$resp->assertStatus(404);
|
||||
}
|
||||
|
||||
public function test_update_endpoint()
|
||||
{
|
||||
$this->actingAsApiAdmin();
|
||||
|
Reference in New Issue
Block a user