Don't allow allocations to be deleted by users if no limit is defined; closes #3703
This commit is contained in:
parent
c751ce7f44
commit
e88d24e0db
7 changed files with 68 additions and 19 deletions
|
@ -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.');
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
namespace Pterodactyl\Models;
|
||||
|
||||
/**
|
||||
* Pterodactyl\Models\Allocation.
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $node_id
|
||||
* @property string $ip
|
||||
|
@ -16,6 +18,22 @@ namespace Pterodactyl\Models;
|
|||
* @property bool $has_alias
|
||||
* @property \Pterodactyl\Models\Server|null $server
|
||||
* @property \Pterodactyl\Models\Node $node
|
||||
* @property string $hashid
|
||||
*
|
||||
* @method static \Database\Factories\AllocationFactory factory(...$parameters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Allocation newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Allocation newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Allocation query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Allocation whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Allocation whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Allocation whereIp($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Allocation whereIpAlias($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Allocation whereNodeId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Allocation whereNotes($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Allocation wherePort($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Allocation whereServerId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Allocation whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Allocation extends Model
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue