Don't allow allocations to be deleted by users if no limit is defined; closes #3703

This commit is contained in:
DaneEveritt 2022-05-07 15:05:28 -04:00
parent c751ce7f44
commit e88d24e0db
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
7 changed files with 68 additions and 19 deletions

View file

@ -120,6 +120,12 @@ class NetworkAllocationController extends ClientApiController
*/
public function delete(DeleteAllocationRequest $request, Server $server, Allocation $allocation)
{
// Don't allow the deletion of allocations if the server does not have an
// allocation limit set.
if (empty($server->allocation_limit)) {
throw new DisplayException('You cannot delete allocations for this server: no allocation limit is set.');
}
if ($allocation->id === $server->allocation_id) {
throw new DisplayException('You cannot delete the primary allocation for this server.');
}