mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
[feature] use internal services to check for acl on exports
This commit is contained in:
@@ -14,6 +14,7 @@ namespace Chill\MainBundle\Export;
|
||||
use Chill\MainBundle\Form\Type\Export\ExportType;
|
||||
use Chill\MainBundle\Form\Type\Export\PickCenterType;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Generator;
|
||||
@@ -42,52 +43,38 @@ class ExportManager
|
||||
/**
|
||||
* The collected aggregators, injected by DI.
|
||||
*
|
||||
* @var AggregatorInterface[]
|
||||
* @var array|AggregatorInterface[]
|
||||
*/
|
||||
private $aggregators = [];
|
||||
private array $aggregators = [];
|
||||
|
||||
/**
|
||||
* @var AuthorizationChecker
|
||||
*/
|
||||
private $authorizationChecker;
|
||||
private AuthorizationCheckerInterface $authorizationChecker;
|
||||
|
||||
/**
|
||||
* @var AuthorizationHelper
|
||||
*/
|
||||
private $authorizationHelper;
|
||||
private AuthorizationHelperInterface $authorizationHelper;
|
||||
|
||||
/**
|
||||
* @var EntityManagerInterface
|
||||
*/
|
||||
private $em;
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
/**
|
||||
* Collected Exports, injected by DI.
|
||||
*
|
||||
* @var ExportInterface[]
|
||||
* @var array|ExportInterface[]
|
||||
*/
|
||||
private $exports = [];
|
||||
private array $exports = [];
|
||||
|
||||
/**
|
||||
* The collected filters, injected by DI.
|
||||
*
|
||||
* @var FilterInterface[]
|
||||
* @var array|FilterInterface[]
|
||||
*/
|
||||
private $filters = [];
|
||||
private array $filters = [];
|
||||
|
||||
/**
|
||||
* Collected Formatters, injected by DI.
|
||||
*
|
||||
* @var FormatterInterface[]
|
||||
* @var array|FormatterInterface[]
|
||||
*/
|
||||
private $formatters = [];
|
||||
private array $formatters = [];
|
||||
|
||||
/**
|
||||
* a logger.
|
||||
*
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
private $logger;
|
||||
private LoggerInterface $logger;
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\Security\Core\User\UserInterface
|
||||
@@ -98,7 +85,7 @@ class ExportManager
|
||||
LoggerInterface $logger,
|
||||
EntityManagerInterface $em,
|
||||
AuthorizationCheckerInterface $authorizationChecker,
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
AuthorizationHelperInterface $authorizationHelper,
|
||||
TokenStorageInterface $tokenStorage
|
||||
) {
|
||||
$this->logger = $logger;
|
||||
@@ -547,19 +534,16 @@ class ExportManager
|
||||
. 'an ExportInterface.');
|
||||
}
|
||||
|
||||
if (null === $centers) {
|
||||
$centers = $this->authorizationHelper->getReachableCenters(
|
||||
if (null === $centers || [] === $centers) {
|
||||
// we want to try if at least one center is reachable
|
||||
return [] !== $this->authorizationHelper->getReachableCenters(
|
||||
$this->user,
|
||||
$role
|
||||
);
|
||||
}
|
||||
|
||||
if (count($centers) === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($centers as $center) {
|
||||
if ($this->authorizationChecker->isGranted($role, $center) === false) {
|
||||
if (false === $this->authorizationChecker->isGranted($role, $center)) {
|
||||
//debugging
|
||||
$this->logger->debug('user has no access to element', [
|
||||
'method' => __METHOD__,
|
||||
@@ -568,10 +552,6 @@ class ExportManager
|
||||
'role' => $role,
|
||||
]);
|
||||
|
||||
///// Bypasse les autorisations qui empêche d'afficher les nouveaux exports
|
||||
return true;
|
||||
///// TODO supprimer le return true
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user