Remove suspended & installing fields, replace with single status field
This commit is contained in:
parent
4c29be2e54
commit
a75a347d65
24 changed files with 115 additions and 59 deletions
|
@ -207,7 +207,7 @@ class ServerViewController extends Controller
|
|||
*/
|
||||
public function manage(Request $request, Server $server)
|
||||
{
|
||||
if ($server->installed > 1) {
|
||||
if ($server->status === Server::STATUS_INSTALL_FAILED) {
|
||||
throw new DisplayException(
|
||||
'This server is in a failed install state and cannot be recovered. Please delete and re-create the server.'
|
||||
);
|
||||
|
|
|
@ -228,12 +228,12 @@ class ServersController extends Controller
|
|||
*/
|
||||
public function toggleInstall(Server $server)
|
||||
{
|
||||
if ($server->installed > 1) {
|
||||
if ($server->status === Server::STATUS_INSTALL_FAILED) {
|
||||
throw new DisplayException(trans('admin/server.exceptions.marked_as_failed'));
|
||||
}
|
||||
|
||||
$this->repository->update($server->id, [
|
||||
'installed' => ! $server->installed,
|
||||
'status' => $server->isInstalled() ? Server::STATUS_INSTALLING : null,
|
||||
], true, true);
|
||||
|
||||
$this->alert->success(trans('admin/server.alerts.install_toggled'))->flash();
|
||||
|
|
|
@ -118,10 +118,8 @@ class SftpAuthenticationController extends Controller
|
|||
|
||||
// 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) {
|
||||
throw new BadRequestHttpException(
|
||||
'Server is not installed or is currently suspended.'
|
||||
);
|
||||
if ($server->isSuspended() || !$server->isInstalled()) {
|
||||
throw new BadRequestHttpException('Server is not installed or is currently suspended.');
|
||||
}
|
||||
|
||||
return new JsonResponse([
|
||||
|
|
|
@ -29,7 +29,7 @@ class ServerInstalled
|
|||
);
|
||||
}
|
||||
|
||||
if ($server->installed !== 1) {
|
||||
if (! $server->isInstalled()) {
|
||||
throw new HttpException(
|
||||
Response::HTTP_FORBIDDEN, 'Access to this resource is not allowed due to the current installation state.'
|
||||
);
|
||||
|
|
|
@ -64,7 +64,7 @@ class AuthenticateServerAccess
|
|||
}
|
||||
}
|
||||
|
||||
if ($server->suspended && ! $request->routeIs('api:client:server.resources')) {
|
||||
if ($server->isSuspended() && ! $request->routeIs('api:client:server.resources')) {
|
||||
throw new BadRequestHttpException(
|
||||
'This server is currently suspended and the functionality requested is unavailable.'
|
||||
);
|
||||
|
|
|
@ -63,7 +63,7 @@ class AccessingValidServer
|
|||
$isApiRequest = $request->expectsJson() || $request->is(...$this->config->get('pterodactyl.json_routes', []));
|
||||
$server = $this->repository->getByUuid($attributes instanceof Server ? $attributes->uuid : $attributes);
|
||||
|
||||
if ($server->suspended) {
|
||||
if ($server->isSuspended()) {
|
||||
if ($isApiRequest) {
|
||||
throw new AccessDeniedHttpException('Server is suspended and cannot be accessed.');
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ class AccessingValidServer
|
|||
|
||||
// Servers can have install statuses other than 1 or 0, so don't check
|
||||
// for a bool-type operator here.
|
||||
if ($server->installed !== 1) {
|
||||
if (! $server->isInstalled()) {
|
||||
if ($isApiRequest) {
|
||||
throw new ConflictHttpException('Server is still completing the installation process.');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue