From 6c39288defd8d1a83b10fdeb953cd8ef6067e9af Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Thu, 24 Dec 2020 10:14:10 -0800 Subject: [PATCH] Clarify error messaging for transfers --- app/Exceptions/Http/Server/ServerTransferringException.php | 5 ++++- .../Controllers/Api/Remote/SftpAuthenticationController.php | 2 +- .../Api/Client/Server/AuthenticateServerAccess.php | 2 +- app/Http/Middleware/Server/AccessingValidServer.php | 2 +- app/Services/Servers/SuspensionService.php | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Exceptions/Http/Server/ServerTransferringException.php b/app/Exceptions/Http/Server/ServerTransferringException.php index 91c3f39bd..d36fb8de4 100644 --- a/app/Exceptions/Http/Server/ServerTransferringException.php +++ b/app/Exceptions/Http/Server/ServerTransferringException.php @@ -7,8 +7,11 @@ use Symfony\Component\HttpKernel\Exception\HttpException; class ServerTransferringException extends HttpException { + /** + * ServerTransferringException constructor. + */ public function __construct() { - parent::__construct(Response::HTTP_CONFLICT, 'Server is currently being transferred.'); + parent::__construct(Response::HTTP_CONFLICT, 'This server is currently being transferred to a new machine, please try again laster.'); } } diff --git a/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php b/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php index 31862a567..cab532e81 100644 --- a/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php +++ b/app/Http/Controllers/Api/Remote/SftpAuthenticationController.php @@ -113,7 +113,7 @@ class SftpAuthenticationController extends Controller // Prevent SFTP access to servers that are being transferred. if (! is_null($server->transfer)) { - throw new ServerTransferringException(); + throw new ServerTransferringException; } // Remember, for security purposes, only reveal the existence of the server to people that diff --git a/app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php b/app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php index 16713b77b..e9eaa143e 100644 --- a/app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php +++ b/app/Http/Middleware/Api/Client/Server/AuthenticateServerAccess.php @@ -82,7 +82,7 @@ class AuthenticateServerAccess if (! is_null($server->transfer)) { if (! $user->root_admin || ($user->root_admin && ! $request->routeIs($this->except))) { - throw new ServerTransferringException(); + throw new ServerTransferringException; } } } diff --git a/app/Http/Middleware/Server/AccessingValidServer.php b/app/Http/Middleware/Server/AccessingValidServer.php index 9c73112dc..2491414c7 100644 --- a/app/Http/Middleware/Server/AccessingValidServer.php +++ b/app/Http/Middleware/Server/AccessingValidServer.php @@ -83,7 +83,7 @@ class AccessingValidServer if (! is_null($server->transfer)) { if ($isApiRequest) { - throw new ServerTransferringException(); + throw new ServerTransferringException; } return $this->response->view('errors.transferring', [], 409); diff --git a/app/Services/Servers/SuspensionService.php b/app/Services/Servers/SuspensionService.php index 83de0ad08..87fd0a334 100644 --- a/app/Services/Servers/SuspensionService.php +++ b/app/Services/Servers/SuspensionService.php @@ -60,7 +60,7 @@ class SuspensionService // Check if the server is currently being transferred. if (! is_null($server->transfer)) { - throw new ServerTransferringException(); + throw new ServerTransferringException; } $this->connection->transaction(function () use ($action, $server) {