Replace api key repository
This commit is contained in:
parent
860b2d890b
commit
28e0668b76
6 changed files with 28 additions and 105 deletions
|
@ -4,6 +4,7 @@ namespace Pterodactyl\Http\Controllers\Admin;
|
|||
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\User;
|
||||
use Illuminate\Http\Response;
|
||||
use Pterodactyl\Models\ApiKey;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
@ -12,7 +13,6 @@ use Pterodactyl\Services\Acl\Api\AdminAcl;
|
|||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Api\KeyCreationService;
|
||||
use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface;
|
||||
use Pterodactyl\Http\Requests\Admin\Api\StoreApplicationApiKeyRequest;
|
||||
|
||||
class ApiController extends Controller
|
||||
|
@ -22,7 +22,6 @@ class ApiController extends Controller
|
|||
*/
|
||||
public function __construct(
|
||||
private AlertsMessageBag $alert,
|
||||
private ApiKeyRepositoryInterface $repository,
|
||||
private KeyCreationService $keyCreationService,
|
||||
private ViewFactory $view,
|
||||
) {
|
||||
|
@ -33,8 +32,15 @@ class ApiController extends Controller
|
|||
*/
|
||||
public function index(Request $request): View
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = $request->user();
|
||||
|
||||
$keys = $user->apiKeys()
|
||||
->where('key_type', ApiKey::TYPE_APPLICATION)
|
||||
->get();
|
||||
|
||||
return $this->view->make('admin.api.index', [
|
||||
'keys' => $this->repository->getApplicationKeys($request->user()),
|
||||
'keys' => $keys,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -80,7 +86,13 @@ class ApiController extends Controller
|
|||
*/
|
||||
public function delete(Request $request, string $identifier): Response
|
||||
{
|
||||
$this->repository->deleteApplicationKey($request->user(), $identifier);
|
||||
/** @var User $user */
|
||||
$user = $request->user();
|
||||
|
||||
$user->apiKeys()
|
||||
->where('key_type', ApiKey::TYPE_APPLICATION)
|
||||
->where('identifier', $identifier)
|
||||
->delete();
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue