|
@@ -12,6 +12,7 @@ use App\Entity\Organization\Subdomain;
|
|
|
use App\Repository\Organization\SubdomainRepository;
|
|
use App\Repository\Organization\SubdomainRepository;
|
|
|
use App\Service\Typo3\SubdomainService;
|
|
use App\Service\Typo3\SubdomainService;
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
|
|
+use Symfony\Bundle\SecurityBundle\Security;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Custom Processor gérant la resource Subdomain
|
|
* Custom Processor gérant la resource Subdomain
|
|
@@ -19,7 +20,8 @@ use Doctrine\ORM\EntityManagerInterface;
|
|
|
class SubdomainProcessor implements ProcessorInterface
|
|
class SubdomainProcessor implements ProcessorInterface
|
|
|
{
|
|
{
|
|
|
public function __construct(
|
|
public function __construct(
|
|
|
- private readonly SubdomainService $subdomainService
|
|
|
|
|
|
|
+ private readonly SubdomainService $subdomainService,
|
|
|
|
|
+ private Security $security
|
|
|
) {}
|
|
) {}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -36,6 +38,12 @@ class SubdomainProcessor implements ProcessorInterface
|
|
|
throw new \RuntimeException('not supported', 500);
|
|
throw new \RuntimeException('not supported', 500);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $access = $this->security->getUser();
|
|
|
|
|
+ if ($data->getOrganization()->getId() !== $access->getOrganization()->getId()) {
|
|
|
|
|
+ // TODO: voir à déplacer dans un voter?
|
|
|
|
|
+ throw new \RuntimeException('forbidden', 500);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if ($operation instanceof Post) {
|
|
if ($operation instanceof Post) {
|
|
|
// Create a new subdomain
|
|
// Create a new subdomain
|
|
|
$subdomain = $this->subdomainService->addNewSubdomain(
|
|
$subdomain = $this->subdomainService->addNewSubdomain(
|