NOW MANAGED ON CODEBERG
Added check of owner field for manage-permissions-own
Dan Brownbbfb330b9214
diff --git a/app/Auth/Permissions/PermissionService.php b/app/Auth/Permissions/PermissionService.phpindex d858a7c18..89c8a5fbb 100644--- a/app/Auth/Permissions/PermissionService.php+++ b/app/Auth/Permissions/PermissionService.php@@ -533,7 +533,8 @@ class PermissionService$allPermission = $this->currentUser() && $this->currentUser()->can($permission . '-all');$ownPermission = $this->currentUser() && $this->currentUser()->can($permission . '-own');$this->currentAction = 'view';- $isOwner = $this->currentUser() && $this->currentUser()->id === $ownable->created_by;+ $ownerField = ($ownable instanceof Entity) ? 'owned_by' : 'created_by';+ $isOwner = $this->currentUser() && $this->currentUser()->id === $ownable->$ownerField;return ($allPermission || ($isOwner && $ownPermission));}diff --git a/tests/Permissions/RolesTest.php b/tests/Permissions/RolesTest.phpindex 3397ef429..8398d0828 100644--- a/tests/Permissions/RolesTest.php+++ b/tests/Permissions/RolesTest.php@@ -216,15 +216,23 @@ class RolesTest extends BrowserKitTest{$otherUsersPage = Page::first();$content = $this->createEntityChainBelongingToUser($this->user);++ // Set a different creator on the page we're checking to ensure+ // that the owner fields are checked+ $page = $content['page']; /** @var Page $page */+ $page->created_by = $otherUsersPage->id;+ $page->owned_by = $this->user->id;+ $page->save();+// Check can't restrict other's content$this->actingAs($this->user)->visit($otherUsersPage->getUrl())->dontSee('Permissions')->visit($otherUsersPage->getUrl() . '/permissions')->seePageIs('/');// Check can't restrict own content- $this->actingAs($this->user)->visit($content['page']->getUrl())+ $this->actingAs($this->user)->visit($page->getUrl())->dontSee('Permissions')- ->visit($content['page']->getUrl() . '/permissions')+ ->visit($page->getUrl() . '/permissions')->seePageIs('/');$this->giveUserPermissions($this->user, ['restrictions-manage-own']);@@ -235,10 +243,10 @@ class RolesTest extends BrowserKitTest->visit($otherUsersPage->getUrl() . '/permissions')->seePageIs('/');// Check can restrict own content- $this->actingAs($this->user)->visit($content['page']->getUrl())+ $this->actingAs($this->user)->visit($page->getUrl())->see('Permissions')->click('Permissions')- ->seePageIs($content['page']->getUrl() . '/permissions');+ ->seePageIs($page->getUrl() . '/permissions');}/**