2017-08-26 18:31:18 +00:00
|
|
|
<?php
|
2017-09-26 02:43:01 +00:00
|
|
|
/**
|
2017-08-26 18:31:18 +00:00
|
|
|
* Pterodactyl - Panel
|
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
|
|
|
*
|
2017-09-26 02:43:01 +00:00
|
|
|
* This software is licensed under the terms of the MIT license.
|
|
|
|
* https://opensource.org/licenses/MIT
|
2017-08-26 18:31:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Pterodactyl\Services\Subusers;
|
|
|
|
|
2017-09-25 03:28:16 +00:00
|
|
|
use Pterodactyl\Models\Subuser;
|
2017-08-26 18:31:18 +00:00
|
|
|
use Illuminate\Database\ConnectionInterface;
|
2017-09-25 02:12:30 +00:00
|
|
|
use Pterodactyl\Services\DaemonKeys\DaemonKeyDeletionService;
|
2017-08-26 18:31:18 +00:00
|
|
|
use Pterodactyl\Contracts\Repository\SubuserRepositoryInterface;
|
|
|
|
|
|
|
|
class SubuserDeletionService
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \Illuminate\Database\ConnectionInterface
|
|
|
|
*/
|
2017-11-03 21:52:18 +00:00
|
|
|
private $connection;
|
2017-08-26 18:31:18 +00:00
|
|
|
|
|
|
|
/**
|
2017-09-25 02:12:30 +00:00
|
|
|
* @var \Pterodactyl\Services\DaemonKeys\DaemonKeyDeletionService
|
2017-08-26 18:31:18 +00:00
|
|
|
*/
|
2017-11-03 21:52:18 +00:00
|
|
|
private $keyDeletionService;
|
2017-08-26 18:31:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Contracts\Repository\SubuserRepositoryInterface
|
|
|
|
*/
|
2017-11-03 21:52:18 +00:00
|
|
|
private $repository;
|
2017-08-26 18:31:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SubuserDeletionService constructor.
|
|
|
|
*
|
2019-09-06 04:32:57 +00:00
|
|
|
* @param \Illuminate\Database\ConnectionInterface $connection
|
|
|
|
* @param \Pterodactyl\Services\DaemonKeys\DaemonKeyDeletionService $keyDeletionService
|
2017-09-25 02:12:30 +00:00
|
|
|
* @param \Pterodactyl\Contracts\Repository\SubuserRepositoryInterface $repository
|
2017-08-26 18:31:18 +00:00
|
|
|
*/
|
|
|
|
public function __construct(
|
|
|
|
ConnectionInterface $connection,
|
2017-09-25 02:12:30 +00:00
|
|
|
DaemonKeyDeletionService $keyDeletionService,
|
|
|
|
SubuserRepositoryInterface $repository
|
2017-08-26 18:31:18 +00:00
|
|
|
) {
|
|
|
|
$this->connection = $connection;
|
2017-09-25 02:12:30 +00:00
|
|
|
$this->keyDeletionService = $keyDeletionService;
|
2017-08-26 18:31:18 +00:00
|
|
|
$this->repository = $repository;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete a subuser and their associated permissions from the Panel and Daemon.
|
|
|
|
*
|
2017-10-28 02:42:53 +00:00
|
|
|
* @param \Pterodactyl\Models\Subuser $subuser
|
2017-08-26 18:31:18 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
|
|
*/
|
2017-10-28 02:42:53 +00:00
|
|
|
public function handle(Subuser $subuser)
|
2017-08-26 18:31:18 +00:00
|
|
|
{
|
|
|
|
$this->connection->beginTransaction();
|
2017-09-25 02:12:30 +00:00
|
|
|
$this->keyDeletionService->handle($subuser->server_id, $subuser->user_id);
|
|
|
|
$this->repository->delete($subuser->id);
|
|
|
|
$this->connection->commit();
|
2017-08-26 18:31:18 +00:00
|
|
|
}
|
|
|
|
}
|