Commit 7f0fb237 authored by Thomas Citharel's avatar Thomas Citharel 🌲

Fix check on existing domains

Signed-off-by: Thomas Citharel's avatarThomas Citharel <tcit@tcit.fr>
parent ced3a9e9
Pipeline #44593 passed with stage
in 4 minutes and 30 seconds
......@@ -4,7 +4,6 @@ namespace AppBundle\Form;
use AppBundle\Entity\Domain;
use AppBundle\Entity\Site;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
......
......@@ -68,8 +68,10 @@ class AttachDomainService extends BaseService
$domain->setStatus(Domain::DOMAIN_WAITING_CONFIGURATION);
$site = $domain->getSite();
if ($this->entityManager->getRepository('AppBundle:Domain')->findOneBy(['domainName' => $domain->getDomainName()])) {
throw new AccessDeniedException('This domain is already attached');
if ($domain = $this->entityManager->getRepository('AppBundle:Domain')->findOneBy(['domainName' => $domain->getDomainName()])) {
if ($domain->getStatus() >= Domain::DOMAIN_OK && $domain->getStatus() < Domain::DOMAIN_DETACHED) {
throw new AccessDeniedException('This domain is already attached');
}
}
$this->entityManager->persist($domain);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment