api(application): v2 backport
This commit is contained in:
parent
4cd0bee231
commit
67bf3e342e
172 changed files with 2922 additions and 1579 deletions
|
@ -6,15 +6,15 @@ use Pterodactyl\Models\Database;
|
|||
use League\Fractal\Resource\Item;
|
||||
use Pterodactyl\Models\Permission;
|
||||
use League\Fractal\Resource\NullResource;
|
||||
use Pterodactyl\Transformers\Api\Transformer;
|
||||
use Illuminate\Contracts\Encryption\Encrypter;
|
||||
use Pterodactyl\Contracts\Extensions\HashidsInterface;
|
||||
|
||||
class DatabaseTransformer extends BaseClientTransformer
|
||||
class DatabaseTransformer extends Transformer
|
||||
{
|
||||
protected array $availableIncludes = ['password'];
|
||||
|
||||
private Encrypter $encrypter;
|
||||
|
||||
private HashidsInterface $hashids;
|
||||
|
||||
/**
|
||||
|
@ -38,8 +38,8 @@ class DatabaseTransformer extends BaseClientTransformer
|
|||
return [
|
||||
'id' => $this->hashids->encode($model->id),
|
||||
'host' => [
|
||||
'address' => $model->getRelation('host')->host,
|
||||
'port' => $model->getRelation('host')->port,
|
||||
'address' => $model->host->host,
|
||||
'port' => $model->host->port,
|
||||
],
|
||||
'name' => $model->database,
|
||||
'username' => $model->username,
|
||||
|
@ -53,7 +53,7 @@ class DatabaseTransformer extends BaseClientTransformer
|
|||
*/
|
||||
public function includePassword(Database $database): Item|NullResource
|
||||
{
|
||||
if (!$this->request->user()->can(Permission::ACTION_DATABASE_VIEW_PASSWORD, $database->server)) {
|
||||
if ($this->user()->cannot(Permission::ACTION_DATABASE_VIEW_PASSWORD, $database->server)) {
|
||||
return $this->null();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue