f9fc3f4370
Main difference is permissions, cleaner UI for normal users, and account keys use permissions assigned to servers and subusers while application keys use R/W ACLs stored in the key table.
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Pterodactyl\Repositories\Eloquent;
|
|
|
|
use Pterodactyl\Models\User;
|
|
use Pterodactyl\Models\ApiKey;
|
|
use Illuminate\Support\Collection;
|
|
use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface;
|
|
|
|
class ApiKeyRepository extends EloquentRepository implements ApiKeyRepositoryInterface
|
|
{
|
|
/**
|
|
* Return the model backing this repository.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function model()
|
|
{
|
|
return ApiKey::class;
|
|
}
|
|
|
|
/**
|
|
* Get all of the account API keys that exist for a specific user.
|
|
*
|
|
* @param \Pterodactyl\Models\User $user
|
|
* @return \Illuminate\Support\Collection
|
|
*/
|
|
public function getAccountKeys(User $user): Collection
|
|
{
|
|
return $this->getBuilder()->where('user_id', $user->id)
|
|
->where('key_type', ApiKey::TYPE_ACCOUNT)
|
|
->get($this->getColumns());
|
|
}
|
|
|
|
/**
|
|
* Delete an account API key from the panel for a specific user.
|
|
*
|
|
* @param \Pterodactyl\Models\User $user
|
|
* @param string $identifier
|
|
* @return int
|
|
*/
|
|
public function deleteAccountKey(User $user, string $identifier): int
|
|
{
|
|
return $this->getBuilder()->where('user_id', $user->id)
|
|
->where('key_type', ApiKey::TYPE_ACCOUNT)
|
|
->where('identifier', $identifier)
|
|
->delete();
|
|
}
|
|
}
|