mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 14:34:44 +02:00
Fix AutoDeploy & KeyCreationService (#701)
* Fix AutoDeploy & KeyCreationService * Get rid of 2nd param & unset perm
This commit is contained in:
parent
b3501be6ec
commit
8eebb82eba
@ -68,7 +68,8 @@ class ApiController extends Controller
|
||||
$this->keyCreationService->setKeyType(ApiKey::TYPE_APPLICATION)->handle([
|
||||
'memo' => $request->input('memo'),
|
||||
'user_id' => $request->user()->id,
|
||||
], $request->getKeyPermissions());
|
||||
'permissions' => $request->getKeyPermissions(),
|
||||
]);
|
||||
|
||||
$this->alert->success('A new application API key has been generated for your account.')->flash();
|
||||
|
||||
|
@ -26,7 +26,7 @@ class KeyCreationService
|
||||
*
|
||||
* @throws \App\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function handle(array $data, array $permissions = []): ApiKey
|
||||
public function handle(array $data): ApiKey
|
||||
{
|
||||
$data = array_merge($data, [
|
||||
'key_type' => $this->keyType,
|
||||
@ -34,8 +34,8 @@ class KeyCreationService
|
||||
'token' => str_random(ApiKey::KEY_LENGTH),
|
||||
]);
|
||||
|
||||
if ($this->keyType === ApiKey::TYPE_APPLICATION) {
|
||||
$data['permissions'] = array_merge($data['permissions'], $permissions);
|
||||
if ($this->keyType !== ApiKey::TYPE_APPLICATION) {
|
||||
unset($data['permissions']);
|
||||
}
|
||||
|
||||
return ApiKey::query()->forceCreate($data);
|
||||
|
@ -38,7 +38,8 @@ class NodeAutoDeployService
|
||||
$key = $this->keyCreationService->setKeyType(ApiKey::TYPE_APPLICATION)->handle([
|
||||
'memo' => 'Automatically generated node deployment key.',
|
||||
'user_id' => $request->user()->id,
|
||||
], ['permissions' => [Node::RESOURCE_NAME => AdminAcl::READ]]);
|
||||
'permissions' => [Node::RESOURCE_NAME => AdminAcl::READ],
|
||||
]);
|
||||
}
|
||||
|
||||
$token = $key->identifier . $key->token;
|
||||
|
Loading…
x
Reference in New Issue
Block a user