2017-08-26 18:31:18 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Pterodactyl - Panel
|
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Pterodactyl\Services\Subusers;
|
|
|
|
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
protected $connection;
|
|
|
|
|
|
|
|
/**
|
2017-09-25 02:12:30 +00:00
|
|
|
* @var \Pterodactyl\Services\DaemonKeys\DaemonKeyDeletionService
|
2017-08-26 18:31:18 +00:00
|
|
|
*/
|
2017-09-25 02:12:30 +00:00
|
|
|
protected $keyDeletionService;
|
2017-08-26 18:31:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Contracts\Repository\SubuserRepositoryInterface
|
|
|
|
*/
|
|
|
|
protected $repository;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SubuserDeletionService constructor.
|
|
|
|
*
|
2017-09-25 02:12:30 +00:00
|
|
|
* @param \Illuminate\Database\ConnectionInterface $connection
|
|
|
|
* @param \Pterodactyl\Services\DaemonKeys\DaemonKeyDeletionService $keyDeletionService
|
|
|
|
* @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.
|
|
|
|
*
|
|
|
|
* @param int $subuser
|
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
|
|
*/
|
|
|
|
public function handle($subuser)
|
|
|
|
{
|
2017-08-26 23:08:11 +00:00
|
|
|
$subuser = $this->repository->getWithServer($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
|
|
|
}
|
|
|
|
}
|