Skip to content

Commit

Permalink
Fix permission check
Browse files Browse the repository at this point in the history
  • Loading branch information
dmolineus committed Sep 23, 2024
1 parent 260ae0d commit 95c91b5
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions src/Security/PagePermissionGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

namespace Hofff\Contao\Navigation\Security;

use Contao\FrontendUser;
use Contao\CoreBundle\Security\ContaoCorePermissions;
use Contao\ModuleModel;
use Contao\StringUtil;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface AS Security;

use function array_intersect;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface as Security;

final class PagePermissionGuard
{
Expand Down Expand Up @@ -74,18 +72,9 @@ public function isPermissionDenied(array $page): bool
return false;
}

$user = $this->security->getUser();
if (! $user instanceof FrontendUser) {
return true;
}

// the current user is not in any group
/** @psalm-suppress RiskyTruthyFalsyComparison */
if (! $user->groups) {
return true;
}

// check if the current user is not in any group, which is allowed to access the current page
return ! array_intersect((array) $user->groups, StringUtil::deserialize($page['groups'], true));
return ! $this->security->isGranted(
ContaoCorePermissions::MEMBER_IN_GROUPS,
StringUtil::deserialize($page['groups'], true),
);
}
}

0 comments on commit 95c91b5

Please sign in to comment.