Skip to content

Commit 6e8c4db

Browse files
authored
IBX-9838: Fixed edit option in three-dot menu remains clickable despite insufficient user permissions (#1525)
* fixed edit permission check * implemented suggested changes * small refactor of initial fix * phpstan fix
1 parent 1c3174a commit 6e8c4db

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/bundle/Controller/Content/ContentTreeController.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ContentTreeController extends RestController
4949

5050
private ConfigResolverInterface $configResolver;
5151

52-
private SiteaccessResolverInterface $siteaccessResolver;
52+
private SiteaccessResolverInterface $siteaccessResolver;
5353

5454
public function __construct(
5555
LocationService $locationService,
@@ -226,7 +226,7 @@ private function getLocationPermissionRestrictions(Location $location): array
226226
'restrictedLanguageCodes' => $createLimitationsValues[Limitation::LANGUAGE],
227227
],
228228
'edit' => [
229-
'hasAccess' => $lookupUpdateLimitationsResult->hasAccess(),
229+
'hasAccess' => $this->canUserEditContent($location),
230230
// skipped content type limitation values as in this case it can be inferred from "hasAccess" above
231231
'restrictedLanguageCodes' => $updateLimitationsValues[Limitation::LANGUAGE],
232232
],
@@ -325,6 +325,20 @@ private function isPreviewable(
325325

326326
return !empty($siteAccesses);
327327
}
328+
329+
/**
330+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException
331+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
332+
*/
333+
private function canUserEditContent(Location $location): bool
334+
{
335+
return $this->permissionResolver->canUser(
336+
'content',
337+
'edit',
338+
$location->getContent(),
339+
[$location]
340+
);
341+
}
328342
}
329343

330344
class_alias(ContentTreeController::class, 'EzSystems\EzPlatformAdminUiBundle\Controller\Content\ContentTreeController');

src/bundle/Controller/ContentController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ public function proxyCreateAction(
216216
public function editAction(Request $request): Response
217217
{
218218
/* @todo it shouldn't rely on keys from request */
219+
/** @var string[] $requestKeys */
219220
$requestKeys = $request->request->keys();
220221
$formName = $request->query->get(
221222
'formName',

0 commit comments

Comments
 (0)