Add ServerTransferringException, use is_null
This commit is contained in:
parent
5668a780e2
commit
fd848985ee
9 changed files with 36 additions and 14 deletions
|
@ -61,7 +61,7 @@ class WebsocketController extends ClientApiController
|
|||
$permissions = $this->permissionsService->handle($server, $user);
|
||||
|
||||
$node = null;
|
||||
if ($server->transfer !== null) {
|
||||
if (! is_null($server->transfer)) {
|
||||
// Check if the user has permissions to receive transfer logs.
|
||||
if (! in_array('admin.websocket.transfer', $permissions)) {
|
||||
throw new HttpException(Response::HTTP_FORBIDDEN, 'You do not have permission to view transfer logs');
|
||||
|
|
|
@ -12,6 +12,7 @@ use Pterodactyl\Exceptions\Http\HttpForbiddenException;
|
|||
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
||||
use Pterodactyl\Services\Servers\GetUserPermissionsService;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Pterodactyl\Exceptions\Http\Server\ServerTransferringException;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Pterodactyl\Http\Requests\Api\Remote\SftpAuthenticationFormRequest;
|
||||
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
|
||||
|
@ -110,9 +111,14 @@ class SftpAuthenticationController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
// Remeber, for security purposes, only reveal the existence of the server to people that
|
||||
// Prevent SFTP access to servers that are being transferred.
|
||||
if (! is_null($server->transfer)) {
|
||||
throw new ServerTransferringException();
|
||||
}
|
||||
|
||||
// Remember, for security purposes, only reveal the existence of the server to people that
|
||||
// have provided valid credentials, and have permissions to know about it.
|
||||
if ($server->installed !== 1 || $server->suspended || $server->transfer !== null) {
|
||||
if ($server->installed !== 1 || $server->suspended) {
|
||||
throw new BadRequestHttpException(
|
||||
'Server is not installed or is currently suspended.'
|
||||
);
|
||||
|
@ -132,7 +138,7 @@ class SftpAuthenticationController extends Controller
|
|||
* @param \Illuminate\Http\Request $request
|
||||
* @return string
|
||||
*/
|
||||
protected function throttleKey(Request $request)
|
||||
protected function throttleKey(Request $request): string
|
||||
{
|
||||
$username = explode('.', strrev($request->input('username', '')));
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class AuthenticateServerAccess
|
|||
}
|
||||
}
|
||||
|
||||
if ($server->transfer !== null) {
|
||||
if (! is_null($server->transfer)) {
|
||||
if (! $user->root_admin || ($user->root_admin && ! $request->routeIs($this->except))) {
|
||||
throw new ConflictHttpException('Server is currently being transferred.');
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ use Illuminate\Contracts\Routing\ResponseFactory;
|
|||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
|
||||
use Pterodactyl\Exceptions\Http\Server\ServerTransferringException;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
class AccessingValidServer
|
||||
|
@ -80,9 +81,9 @@ class AccessingValidServer
|
|||
return $this->response->view('errors.installing', [], 409);
|
||||
}
|
||||
|
||||
if ($server->transfer !== null) {
|
||||
if (! is_null($server->transfer)) {
|
||||
if ($isApiRequest) {
|
||||
throw new ConflictHttpException('Server is currently being transferred.');
|
||||
throw new ServerTransferringException();
|
||||
}
|
||||
|
||||
return $this->response->view('errors.transferring', [], 409);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue