mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-18 22:33:44 +02:00
Update logic for tracking a server's transfer state
This commit is contained in:
@@ -9,7 +9,6 @@ use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
class AuthenticateServerAccess
|
||||
{
|
||||
@@ -24,7 +23,6 @@ class AuthenticateServerAccess
|
||||
* @var string[]
|
||||
*/
|
||||
protected $except = [
|
||||
'api:client:server.view',
|
||||
'api:client:server.ws',
|
||||
];
|
||||
|
||||
@@ -65,17 +63,26 @@ class AuthenticateServerAccess
|
||||
}
|
||||
}
|
||||
|
||||
if ($server->suspended && !$request->routeIs('api:client:server.resources')) {
|
||||
if ($server->suspended && ! $request->routeIs('api:client:server.resources')) {
|
||||
throw new BadRequestHttpException(
|
||||
'This server is currently suspended and the functionality requested is unavailable.'
|
||||
);
|
||||
}
|
||||
|
||||
if (! $server->isInstalled()) {
|
||||
// Throw an exception for all server routes; however if the user is an admin and requesting the
|
||||
// server details, don't throw the exception for them.
|
||||
if (! $user->root_admin || ($user->root_admin && ! $request->routeIs($this->except))) {
|
||||
throw new ConflictHttpException('Server has not completed the installation process.');
|
||||
// Still allow users to get information about there server if it is installing or being transferred.
|
||||
if (! $request->routeIs('api:client:server.view')) {
|
||||
if (! $server->isInstalled()) {
|
||||
// Throw an exception for all server routes; however if the user is an admin and requesting the
|
||||
// server details, don't throw the exception for them.
|
||||
if (! $user->root_admin || ($user->root_admin && ! $request->routeIs($this->except))) {
|
||||
throw new ConflictHttpException('Server has not completed the installation process.');
|
||||
}
|
||||
}
|
||||
|
||||
if ($server->transfer !== null) {
|
||||
if (! $user->root_admin || ($user->root_admin && ! $request->routeIs($this->except))) {
|
||||
throw new ConflictHttpException('Server is currently being transferred.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,14 @@ class AccessingValidServer
|
||||
return $this->response->view('errors.installing', [], 409);
|
||||
}
|
||||
|
||||
if ($server->transfer !== null) {
|
||||
if ($isApiRequest) {
|
||||
throw new ConflictHttpException('Server is currently being transferred.');
|
||||
}
|
||||
|
||||
return $this->response->view('errors.transferring', [], 409);
|
||||
}
|
||||
|
||||
// Add server to the request attributes. This will replace sessions
|
||||
// as files are updated.
|
||||
$request->attributes->set('server', $server);
|
||||
|
||||
Reference in New Issue
Block a user