fix(ogcore): permisos DELETE de OUs y borrado de clientes sin plantilla
parent
5ce29848f1
commit
7f56b6291a
|
|
@ -54,7 +54,8 @@
|
|||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"App\\Tests\\": "tests/"
|
||||
"App\\Tests\\": "tests/",
|
||||
"Functional\\": "tests/Functional/"
|
||||
}
|
||||
},
|
||||
"replace": {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue