diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d91074b1..8a3652815 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,18 @@ This file is a running track of new features and fixes to each version of the pa This project follows [Semantic Versioning](http://semver.org) guidelines. +## v0.7.16 (Derelict Dermodactylus) +### Fixed +* Fixed the /api/application/servers endpoint erroring when including subusers or egg +* Fixed bug in migration files causing failures when using MySQL 8. +* Fixed missing redirect return when an error occurs while modifying database information. +* Fixes bug in login attempt tracking. +* Fixes a bug where certain URL encoded files would not be editable in the file manager. + +### Added +* The application API now includes the egg's name in the egg model's response. +* The /api/application/servers endpoint can now include server's databases and subusers. + ## v0.7.15 (Derelict Dermodactylus) ### Fixed * Fixes support for PHP 7.3 when running `composer install` commands due to a dependency that needed updating. diff --git a/app/Http/Controllers/Admin/DatabaseController.php b/app/Http/Controllers/Admin/DatabaseController.php index 5d967352f..569fec1d7 100644 --- a/app/Http/Controllers/Admin/DatabaseController.php +++ b/app/Http/Controllers/Admin/DatabaseController.php @@ -165,7 +165,7 @@ class DatabaseController extends Controller $this->alert->danger( sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage()) )->flash(); - $redirect->withInput($request->normalize()); + return $redirect->withInput($request->normalize()); } else { throw $exception; } diff --git a/app/Models/Server.php b/app/Models/Server.php index d6a343c1c..0db2bfef6 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -203,11 +203,11 @@ class Server extends Validable /** * Gets the subusers associated with a server. * - * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough + * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function subusers() { - return $this->hasManyThrough(User::class, Subuser::class, 'server_id', 'id', 'id', 'user_id'); + return $this->hasMany(Subuser::class, 'server_id', 'id'); } /** diff --git a/app/Services/Nests/NestDeletionService.php b/app/Services/Nests/NestDeletionService.php index f747a7342..990bbc595 100644 --- a/app/Services/Nests/NestDeletionService.php +++ b/app/Services/Nests/NestDeletionService.php @@ -51,7 +51,7 @@ class NestDeletionService { $count = $this->serverRepository->findCountWhere([['nest_id', '=', $nest]]); if ($count > 0) { - throw new HasActiveServersException(trans('exceptions.service.delete_has_servers')); + throw new HasActiveServersException(trans('exceptions.nest.delete_has_servers')); } return $this->repository->delete($nest); diff --git a/app/Transformers/Api/Application/EggTransformer.php b/app/Transformers/Api/Application/EggTransformer.php index 98765bf4c..a3686341e 100644 --- a/app/Transformers/Api/Application/EggTransformer.php +++ b/app/Transformers/Api/Application/EggTransformer.php @@ -41,6 +41,7 @@ class EggTransformer extends BaseTransformer return [ 'id' => $model->id, 'uuid' => $model->uuid, + 'name' => $model->name, 'nest' => $model->nest_id, 'author' => $model->author, 'description' => $model->description, diff --git a/app/Transformers/Api/Application/ServerTransformer.php b/app/Transformers/Api/Application/ServerTransformer.php index 2a542dbcd..70dc185d6 100644 --- a/app/Transformers/Api/Application/ServerTransformer.php +++ b/app/Transformers/Api/Application/ServerTransformer.php @@ -28,6 +28,7 @@ class ServerTransformer extends BaseTransformer 'variables', 'location', 'node', + 'databases', ]; /** @@ -131,7 +132,7 @@ class ServerTransformer extends BaseTransformer $server->loadMissing('subusers'); - return $this->collection($server->getRelation('subusers'), $this->makeTransformer(UserTransformer::class), 'user'); + return $this->collection($server->getRelation('subusers'), $this->makeTransformer(SubuserTransformer::class), 'subuser'); } /** @@ -195,14 +196,14 @@ class ServerTransformer extends BaseTransformer } /** - * Return a generic array with service option information for this server. + * Return a generic array with egg information for this server. * * @param \Pterodactyl\Models\Server $server * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource * * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException */ - public function includeOption(Server $server) + public function includeEgg(Server $server) { if (! $this->authorize(AdminAcl::RESOURCE_EGGS)) { return $this->null(); @@ -210,7 +211,7 @@ class ServerTransformer extends BaseTransformer $server->loadMissing('egg'); - return $this->item($server->getRelation('egg'), $this->makeTransformer(EggVariableTransformer::class), 'egg'); + return $this->item($server->getRelation('egg'), $this->makeTransformer(EggTransformer::class), 'egg'); } /** @@ -269,4 +270,23 @@ class ServerTransformer extends BaseTransformer return $this->item($server->getRelation('node'), $this->makeTransformer(NodeTransformer::class), 'node'); } + + /** + * Return a generic array with database information for this server. + * + * @param \Pterodactyl\Models\Server $server + * @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource + * + * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + */ + public function includeDatabases(Server $server) + { + if (! $this->authorize(AdminAcl::RESOURCE_SERVER_DATABASES)) { + return $this->null(); + } + + $server->loadMissing('databases'); + + return $this->collection($server->getRelation('databases'), $this->makeTransformer(ServerDatabaseTransformer::class), 'databases'); + } } diff --git a/app/Transformers/Api/Application/SubuserTransformer.php b/app/Transformers/Api/Application/SubuserTransformer.php new file mode 100644 index 000000000..7927272ca --- /dev/null +++ b/app/Transformers/Api/Application/SubuserTransformer.php @@ -0,0 +1,85 @@ + $subuser->id, + 'user_id' => $subuser->user_id, + 'server_id' => $subuser->server_id, + 'permissions' => $subuser->permissions->map(function (Permission $permission) { + return $permission->permission; + }), + 'created_at' => $this->formatTimestamp($subuser->created_at), + 'updated_at' => $this->formatTimestamp($subuser->updated_at), + ]; + } + + /** + * Return a generic item of user for this subuser. + * + * @param \Pterodactyl\Models\Subuser $subuser + * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource + * + * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + */ + public function includeUser(Subuser $subuser) + { + if (! $this->authorize(AdminAcl::RESOURCE_USERS)) { + return $this->null(); + } + + $subuser->loadMissing('user'); + + return $this->item($subuser->getRelation('user'), $this->makeTransformer(UserTransformer::class), 'user'); + } + + /** + * Return a generic item of server for this subuser. + * + * @param \Pterodactyl\Models\Subuser $subuser + * @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource + * + * @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException + */ + public function includeServer(Subuser $subuser) + { + if (! $this->authorize(AdminAcl::RESOURCE_SERVERS)) { + return $this->null(); + } + + $subuser->loadMissing('server'); + + return $this->item($subuser->getRelation('server'), $this->makeTransformer(ServerTransformer::class), 'server'); + } +} diff --git a/config/auth.php b/config/auth.php index e83406286..02f4807e4 100644 --- a/config/auth.php +++ b/config/auth.php @@ -12,7 +12,7 @@ return [ | */ 'lockout' => [ - 'time' => 120, + 'time' => 2, 'attempts' => 3, ], diff --git a/database/migrations/2016_10_23_193810_add_foreign_keys_servers.php b/database/migrations/2016_10_23_193810_add_foreign_keys_servers.php index 3a2663527..1412720c9 100644 --- a/database/migrations/2016_10_23_193810_add_foreign_keys_servers.php +++ b/database/migrations/2016_10_23_193810_add_foreign_keys_servers.php @@ -16,7 +16,7 @@ class AddForeignKeysServers extends Migration MODIFY COLUMN owner INT(10) UNSIGNED NOT NULL, MODIFY COLUMN allocation INT(10) UNSIGNED NOT NULL, MODIFY COLUMN service INT(10) UNSIGNED NOT NULL, - MODIFY COLUMN servers.option INT(10) UNSIGNED NOT NULL + MODIFY COLUMN `option` INT(10) UNSIGNED NOT NULL '); Schema::table('servers', function (Blueprint $table) { @@ -55,7 +55,7 @@ class AddForeignKeysServers extends Migration MODIFY COLUMN owner MEDIUMINT(8) UNSIGNED NOT NULL, MODIFY COLUMN allocation MEDIUMINT(8) UNSIGNED NOT NULL, MODIFY COLUMN service MEDIUMINT(8) UNSIGNED NOT NULL, - MODIFY COLUMN servers.option MEDIUMINT(8) UNSIGNED NOT NULL + MODIFY COLUMN `option` MEDIUMINT(8) UNSIGNED NOT NULL '); } } diff --git a/resources/views/admin/eggs/scripts.blade.php b/resources/views/admin/eggs/scripts.blade.php index 55c6f1b9b..9b82b6d5d 100644 --- a/resources/views/admin/eggs/scripts.blade.php +++ b/resources/views/admin/eggs/scripts.blade.php @@ -6,15 +6,16 @@ @extends('layouts.admin') @section('title') - Nests → Egg: {{ $egg->name }} → Scripts + Nests → Egg: {{ $egg->name }} → Install Script @endsection @section('content-header') -
Enter the directory where server files should be stored. If you use OVH you should check your partition scheme. You may need to use /home/daemon-data
to have enough space.