From fb64bb51c6d7ec207c0bfbc40e77a1f35edad748 Mon Sep 17 00:00:00 2001 From: Daniel Berthereau Date: Mon, 8 Apr 2024 00:00:00 +0000 Subject: [PATCH] Fixed assertion OwnsEntityAssertion when the check is done against a doctrine proxy. --- .../src/Permissions/Assertion/OwnsEntityAssertion.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/application/src/Permissions/Assertion/OwnsEntityAssertion.php b/application/src/Permissions/Assertion/OwnsEntityAssertion.php index f148ea69cd..b9dde81f58 100644 --- a/application/src/Permissions/Assertion/OwnsEntityAssertion.php +++ b/application/src/Permissions/Assertion/OwnsEntityAssertion.php @@ -12,9 +12,13 @@ class OwnsEntityAssertion implements AssertionInterface public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null ) { + if (!$role || !$role instanceof \Omeka\Entity\User) { + return false; + } if ($resource instanceof Value) { $resource = $resource->getResource(); } - return $role && $role === $resource->getOwner(); + $owner = $resource->getOwner(); + return $owner && $role->getId() === $owner->getId(); } }