Show console when an admin is viewing an installing server
This commit is contained in:
parent
446dc8b33d
commit
6056b6f45d
4 changed files with 130 additions and 88 deletions
|
@ -17,6 +17,16 @@ class AuthenticateServerAccess
|
|||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* Routes that this middleware should not apply to if the user is an admin.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $except = [
|
||||
'api:client:server.view',
|
||||
'api:client:server.ws',
|
||||
];
|
||||
|
||||
/**
|
||||
* AuthenticateServerAccess constructor.
|
||||
*
|
||||
|
@ -36,6 +46,8 @@ class AuthenticateServerAccess
|
|||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = $request->user();
|
||||
$server = $request->route()->parameter('server');
|
||||
|
||||
if (! $server instanceof Server) {
|
||||
|
@ -45,9 +57,9 @@ class AuthenticateServerAccess
|
|||
// At the very least, ensure that the user trying to make this request is the
|
||||
// server owner, a subuser, or a root admin. We'll leave it up to the controllers
|
||||
// to authenticate more detailed permissions if needed.
|
||||
if ($request->user()->id !== $server->owner_id && ! $request->user()->root_admin) {
|
||||
if ($user->id !== $server->owner_id && ! $user->root_admin) {
|
||||
// Check for subuser status.
|
||||
if (! $server->subusers->contains('user_id', $request->user()->id)) {
|
||||
if (! $server->subusers->contains('user_id', $user->id)) {
|
||||
throw new NotFoundHttpException(trans('exceptions.api.resource_not_found'));
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +69,11 @@ class AuthenticateServerAccess
|
|||
}
|
||||
|
||||
if (! $server->isInstalled()) {
|
||||
throw new ConflictHttpException('Server has not completed the installation process.');
|
||||
// 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.');
|
||||
}
|
||||
}
|
||||
|
||||
$request->attributes->set('server', $server);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue