Skip to content

Commit

Permalink
Update ApiKeyController.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Rene-Roscher authored May 31, 2024
1 parent 5d56865 commit 4a1aba5
Showing 1 changed file with 2 additions and 45 deletions.
47 changes: 2 additions & 45 deletions src/Http/Controllers/ApiKeyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,6 @@

class ApiKeyController extends ApplicationApiController
{
/**
* @var \Pterodactyl\Services\Api\KeyCreationService
*/
//private $keyCreationService;

/**
* @var \Illuminate\Contracts\Encryption\Encrypter
*/
//private $encrypter;

/**
* @var \Pterodactyl\Repositories\Eloquent\ApiKeyRepository
*/
//private $repository;

/**
* ApiKeyController constructor.
*/
//public function __construct(
// Encrypter $encrypter,
// KeyCreationService $keyCreationService,
// ApiKeyRepository $repository
//) {
// parent::__construct();

// $this->encrypter = $encrypter;
// $this->keyCreationService = $keyCreationService;
// $this->repository = $repository;
//}

/**
* Returns all of the API keys that exist for the given client.
*
Expand All @@ -66,23 +36,16 @@ public function index(GetUsersApiKeysRequest $request, User $user)
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function store(StoreApiKeyRequest $request, User $user)
public function store(User $user)
{
//$key = $this->keyCreationService->setKeyType(ApiKey::TYPE_ACCOUNT)->handle([
// 'user_id' => $user->id,
// 'memo' => $request->input('description'),
// 'allowed_ips' => $request->input('allowed_ips') ?? [],
//]);

$token = $user->createToken(
$request->input('description'),
$request->input('allowed_ips')
);

return $this->fractal->item($key)
return $this->fractal->item($token->accessToken)
->transformWith($this->getTransformer(ApiKeyTransformer::class))
->addMeta([
//'secret_token' => $this->encrypter->decrypt($key->token),
'secret_token' => $token->plainTextToken
])
->toArray();
Expand All @@ -95,12 +58,6 @@ public function store(StoreApiKeyRequest $request, User $user)
*/
public function delete(GetUsersApiKeysRequest $request, User $user, string $identifier)
{
//$response = $this->repository->deleteWhere([
// 'key_type' => ApiKey::TYPE_ACCOUNT,
// 'user_id' => $user->id,
// 'identifier' => $identifier,
//]);

$key = $user->apiKeys()
->where('key_type', ApiKey::TYPE_ACCOUNT)
->where('identifier', $identifier)
Expand Down

0 comments on commit 4a1aba5

Please sign in to comment.