Fix suspension/installed handling for servers

closes Pterodactyl/Panel#891
This commit is contained in:
Dane Everitt 2018-01-30 22:40:21 -06:00
parent b0c8390529
commit 7a19019980
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
7 changed files with 71 additions and 29 deletions

View file

@ -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();