|
@@ -53,14 +53,6 @@ class OnSubdomainChange extends OnChangeDefault
|
|
|
$this->bindFileService->registerSubdomain($subdomain->getSubdomain());
|
|
$this->bindFileService->registerSubdomain($subdomain->getSubdomain());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Update the admin username
|
|
|
|
|
- //if ($this->isPutRequest() && $this->previousData()) {
|
|
|
|
|
- // if ($subdomain->isActive() && !$this->previousData()->isActive()) {
|
|
|
|
|
- // $this->onSubdomainChange->updateAdminUsername($subdomain->getOrganization());
|
|
|
|
|
- // $shallPersist = true;
|
|
|
|
|
- // }
|
|
|
|
|
- //}
|
|
|
|
|
-
|
|
|
|
|
if ($shallPersist) {
|
|
if ($shallPersist) {
|
|
|
$this->entityManager->flush();
|
|
$this->entityManager->flush();
|
|
|
}
|
|
}
|
|
@@ -83,34 +75,6 @@ class OnSubdomainChange extends OnChangeDefault
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * Update the admin username to match the pattern 'admin{subdomain}'
|
|
|
|
|
- *
|
|
|
|
|
- * @param Organization $organization
|
|
|
|
|
- */
|
|
|
|
|
- public function updateAdminUsername(Organization $organization): void
|
|
|
|
|
- {
|
|
|
|
|
- $subdomain = \App\Service\Organization\Utils::getOrganizationActiveSubdomain($organization);
|
|
|
|
|
- if (!$subdomain) {
|
|
|
|
|
- throw new \RuntimeException('Organization has no active subdomain : ' . $organization->getId());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $admin = $this->accessUtils->findAdminFor($organization);
|
|
|
|
|
- if (!$admin) {
|
|
|
|
|
- throw new \RuntimeException('No admin found for organization ' . $organization->getId());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $newUsername = 'admin' . $subdomain;
|
|
|
|
|
- /** @noinspection NullPointerExceptionInspection */
|
|
|
|
|
- $admin->getPerson()->setUsername($newUsername);
|
|
|
|
|
-
|
|
|
|
|
- if($this->security->getUser()->getId() === $admin->getId()){
|
|
|
|
|
- // todo : déplacer ça dans un service dédié
|
|
|
|
|
- $jwt = $this->jwtManager->create($admin->getPerson());
|
|
|
|
|
- setcookie('BEARER', $jwt, 0, '/', '.opentalent.fr', false, true);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* @throws \Exception
|
|
* @throws \Exception
|
|
|
*/
|
|
*/
|