Fix up API handling logic for keys and set a prefix on all keys
This commit is contained in:
parent
8605d175d6
commit
b051718afe
11 changed files with 88 additions and 31 deletions
|
@ -63,7 +63,6 @@ class ApiKeyController extends ClientApiController
|
|||
* @return array
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function store(StoreApiKeyRequest $request)
|
||||
{
|
||||
|
@ -71,17 +70,14 @@ class ApiKeyController extends ClientApiController
|
|||
throw new DisplayException('You have reached the account limit for number of API keys.');
|
||||
}
|
||||
|
||||
$key = $this->keyCreationService->setKeyType(ApiKey::TYPE_ACCOUNT)->handle([
|
||||
'user_id' => $request->user()->id,
|
||||
'memo' => $request->input('description'),
|
||||
'allowed_ips' => $request->input('allowed_ips') ?? [],
|
||||
]);
|
||||
$token = $request->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),
|
||||
])
|
||||
->addMeta(['secret_token' => $token->plainTextToken])
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue