fix(ogcore): permisos DELETE de OUs y borrado de clientes sin plantilla

pull/123/head
Nicolas Arenas 2026-06-15 11:52:44 +02:00
parent 5ce29848f1
commit 7f56b6291a
4 changed files with 10 additions and 4 deletions

View File

@ -54,7 +54,8 @@
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
"App\\Tests\\": "tests/",
"Functional\\": "tests/Functional/"
}
},
"replace": {

View File

@ -28,7 +28,10 @@ resources:
groups: ['organizational-unit:patch' ]
ApiPlatform\Metadata\Post:
security: 'is_granted("ROLE_SUPER_ADMIN") or is_granted("ROLE_ORGANIZATIONAL_UNIT_ADMIN")'
ApiPlatform\Metadata\Delete: ~
ApiPlatform\Metadata\Delete:
provider: App\State\Provider\OrganizationalUnitProvider
security: 'is_granted("ROLE_SUPER_ADMIN") or (is_granted("ROLE_ORGANIZATIONAL_UNIT_ADMIN") and object.getCreatedBy() == user.getUserIdentifier())'
securityMessage: 'You can only delete organizational units you created.'
change_parent:
class: ApiPlatform\Metadata\Post
method: POST

View File

@ -25,7 +25,7 @@ class DeleteAction extends AbstractOgBootController
{
$response = $this->createRequest('DELETE', '/ogboot/v1/pxes/'.$mac);
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
if (isset($response['error']) && $response['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
return new JsonResponse( data: 'An error occurred', status: Response::HTTP_INTERNAL_SERVER_ERROR);
}

View File

@ -134,7 +134,9 @@ readonly class ClientProcessor implements ProcessorInterface
if ($client->getSubnet()) {
$this->deleteHostAction->__invoke($client->getSubnet(), $client->getUuid());
}
$this->deletePxeAction->__invoke($client->getMac());
if ($client->getMac() && $client->getTemplate()) {
$this->deletePxeAction->__invoke($client->getMac());
}
}
$this->clientRepository->delete($client);