Skip to content

IBX-9838: FIX Edit option in three-dot menu remains clickable despite insufficient user permissions #1525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 4.6
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/bundle/Controller/Content/ContentTreeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ContentTreeController extends RestController

private ConfigResolverInterface $configResolver;

private SiteaccessResolverInterface $siteaccessResolver;
private SiteaccessResolverInterface $siteaccessResolver;

public function __construct(
LocationService $locationService,
Expand Down Expand Up @@ -226,7 +226,7 @@ private function getLocationPermissionRestrictions(Location $location): array
'restrictedLanguageCodes' => $createLimitationsValues[Limitation::LANGUAGE],
],
'edit' => [
'hasAccess' => $lookupUpdateLimitationsResult->hasAccess(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked other uses of this method? If it does not work correctly, it should be fixed, or all usage should be replaced.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to investigate this one, we have another variable lookupUpdateLimitationsResult thats also not working correctly here, I will come back here once I have done some test.

'hasAccess' => $this->canUserEditContent($location),
// skipped content type limitation values as in this case it can be inferred from "hasAccess" above
'restrictedLanguageCodes' => $updateLimitationsValues[Limitation::LANGUAGE],
],
Expand Down Expand Up @@ -325,6 +325,20 @@ private function isPreviewable(

return !empty($siteAccesses);
}

/**
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
*/
private function canUserEditContent(Location $location): bool
{
return $this->permissionResolver->canUser(
'content',
'edit',
$location->getContent(),
[$location]
);
}
}

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