Fix suspension/installed handling for servers
closes Pterodactyl/Panel#891
This commit is contained in:
parent
b0c8390529
commit
7a19019980
7 changed files with 71 additions and 29 deletions
|
@ -25,6 +25,7 @@
|
|||
namespace Pterodactyl\Http\Controllers\Api\Remote;
|
||||
|
||||
use Spatie\Fractal\Fractal;
|
||||
use Illuminate\Http\Response;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Foundation\Testing\HttpException;
|
||||
|
@ -75,12 +76,11 @@ class ValidateKeyController extends Controller
|
|||
* @return array
|
||||
*
|
||||
* @throws \Illuminate\Foundation\Testing\HttpException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function index($token)
|
||||
{
|
||||
if (! starts_with($token, DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER)) {
|
||||
throw new HttpException(501);
|
||||
throw new HttpException(Response::HTTP_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -89,6 +89,10 @@ class ValidateKeyController extends Controller
|
|||
throw new NotFoundHttpException;
|
||||
}
|
||||
|
||||
if ($key->getRelation('server')->suspended || $key->getRelation('server')->installed !== 1) {
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
|
||||
return $this->fractal->item($key, $this->app->make(ApiKeyTransformer::class), 'server')
|
||||
->serializeWith(JsonApiSerializer::class)
|
||||
->toArray();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue