Commit bac057e0 authored by Thomas Citharel's avatar Thomas Citharel 🌲

Merge branch 'fix-attach-domain-issue' into 'master'

Try to fix attachment domain issue

Closes #125

See merge request framasoft/framasite!98
parents e9f0cf3e fcb86338
Pipeline #45871 passed with stages
in 15 minutes and 1 second
......@@ -117,10 +117,6 @@ class AttachDomainToSite extends ContainerAwareCommand
;
$site->addDomain($domain);
$this->entityManager->persist($site);
$this->entityManager->persist($domain);
$this->entityManager->flush();
try {
$this->attachDomainService->attachDomain($domain, $site->getUser());
......
......@@ -142,15 +142,23 @@ class DomainController extends Controller
if ($attachDomainForm->isSubmitted() && $attachDomainForm->isValid()) {
// create the vhost for the domain
/** @var AttachDomainService $attachDomainService */
$site = $this->attachDomainService->attachDomain($domain, $this->getUser());
try {
/** @var AttachDomainService $attachDomainService */
$site = $this->attachDomainService->attachDomain($domain, $this->getUser());
$this->flashBag->add(
'info',
$this->translator->trans('flashes.domain.attached', ['%domain%' => $domain->getDomainName(), '%site%' => $site->getSubdomain()], 'messages')
);
// send a success (or not ?) notification
return $this->redirectToRoute('homepage');
$this->flashBag->add(
'info',
$this->translator->trans('flashes.domain.attached',
['%domain%' => $domain->getDomainName(), '%site%' => $site->getSubdomain(
)],
'messages'
)
);
// send a success (or not ?) notification
return $this->redirectToRoute('homepage');
} catch (AccessDeniedException $e) {
throw $this->createAccessDeniedException($e->getMessage());
}
}
$v4 = @dns_get_record('frama.site', DNS_A)[0]['ip'];
......
......@@ -68,12 +68,11 @@ class AttachDomainService extends BaseService
$domain->setStatus(Domain::DOMAIN_WAITING_CONFIGURATION);
$site = $domain->getSite();
if ($domain = $this->entityManager->getRepository('AppBundle:Domain')->findOneBy(['domainName' => $domain->getDomainName()])) {
if ($domain->getStatus() >= Domain::DOMAIN_OK && $domain->getStatus() < Domain::DOMAIN_DETACHED) {
if ($existingDomain = $this->entityManager->getRepository('AppBundle:Domain')->findOneBy(['domainName' => $domain->getDomainName()])) {
if ($existingDomain->getStatus() >= Domain::DOMAIN_OK && $existingDomain->getStatus() < Domain::DOMAIN_DETACHED) {
throw new AccessDeniedException('This domain is already attached');
}
}
$this->entityManager->persist($domain);
$this->entityManager->persist($site);
$this->entityManager->flush();
......
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