From 917e5e19aa9c0a5721bfb915c4d4c0fa1bb8c9e4 Mon Sep 17 00:00:00 2001 From: Oreo Oreoniv <28255085+zKoz210@users.noreply.github.com> Date: Mon, 5 Aug 2019 20:02:31 +0300 Subject: [PATCH 01/16] Fixed RegEx validate database password (#1667) --- tests/Unit/Services/Databases/DatabasePasswordServiceTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/Services/Databases/DatabasePasswordServiceTest.php b/tests/Unit/Services/Databases/DatabasePasswordServiceTest.php index c01793677..6edb79022 100644 --- a/tests/Unit/Services/Databases/DatabasePasswordServiceTest.php +++ b/tests/Unit/Services/Databases/DatabasePasswordServiceTest.php @@ -60,7 +60,7 @@ class DatabasePasswordServiceTest extends TestCase $this->dynamic->shouldReceive('set')->with('dynamic', $model->database_host_id)->once()->andReturnNull(); $this->encrypter->expects('encrypt')->with(m::on(function ($string) { - preg_match_all('/[!@+=^-]/', $string, $matches, PREG_SET_ORDER); + preg_match_all('/[!@+=.^-]/', $string, $matches, PREG_SET_ORDER); $this->assertTrue(count($matches) >= 2 && count($matches) <= 6, "Failed asserting that [{$string}] contains 2 to 6 special characters."); $this->assertTrue(strlen($string) === 24, "Failed asserting that [{$string}] is 24 characters in length."); From 20c594ae3b99ad91d8f9ccb5706e059afd44297a Mon Sep 17 00:00:00 2001 From: TrixterTheTux Date: Sat, 24 Aug 2019 15:47:11 +0300 Subject: [PATCH 02/16] Include the egg name in egg model's response from the application API --- CHANGELOG.md | 4 ++++ app/Transformers/Api/Application/EggTransformer.php | 1 + 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22858333d..1d2edc870 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ 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) +### Added +* The application API now includes the egg's name in the egg model's response. + ## 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/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, From ab09c7db28cc8ae80b4dc17465a3c740f05cb107 Mon Sep 17 00:00:00 2001 From: TrixterTheTux Date: Sat, 31 Aug 2019 11:29:44 +0300 Subject: [PATCH 03/16] Fix couple of issues with /api/application/servers --- CHANGELOG.md | 4 + .../Api/Application/ServerTransformer.php | 28 ++++++- .../Api/Application/SubuserTransformer.php | 80 +++++++++++++++++++ 3 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 app/Transformers/Api/Application/SubuserTransformer.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d2edc870..434234272 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,12 @@ 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 + ### 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 diff --git a/app/Transformers/Api/Application/ServerTransformer.php b/app/Transformers/Api/Application/ServerTransformer.php index 2a542dbcd..27e377e2d 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), 'user'); } /** @@ -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..1bb5d6017 --- /dev/null +++ b/app/Transformers/Api/Application/SubuserTransformer.php @@ -0,0 +1,80 @@ + $subuser->id, + 'permissions' => $subuser->permissions->toArray(), + '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'); + } +} From 03dba1a00acbbb7cf3fafe5540d05d309271f01d Mon Sep 17 00:00:00 2001 From: AreYouScared Date: Fri, 4 Oct 2019 01:14:47 -0400 Subject: [PATCH 04/16] Fixed has servers error message Fixed "Nest has active servers error" --- app/Services/Nests/NestDeletionService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Services/Nests/NestDeletionService.php b/app/Services/Nests/NestDeletionService.php index 6bdaf8de2..0f01a5e58 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); From 771d30cc11b053d4388d99bea94e13fe795a852f Mon Sep 17 00:00:00 2001 From: Arnaud Lier Date: Tue, 15 Oct 2019 01:50:58 +0200 Subject: [PATCH 05/16] Fix Nest deletion service unit test (#1721) --- tests/Unit/Services/Nests/NestDeletionServiceTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/Services/Nests/NestDeletionServiceTest.php b/tests/Unit/Services/Nests/NestDeletionServiceTest.php index 28fcc7517..29fd9d559 100644 --- a/tests/Unit/Services/Nests/NestDeletionServiceTest.php +++ b/tests/Unit/Services/Nests/NestDeletionServiceTest.php @@ -73,7 +73,7 @@ class NestDeletionServiceTest extends TestCase $this->service->handle(1); } catch (PterodactylException $exception) { $this->assertInstanceOf(HasActiveServersException::class, $exception); - $this->assertEquals(trans('exceptions.service.delete_has_servers'), $exception->getMessage()); + $this->assertEquals(trans('exceptions.nest.delete_has_servers'), $exception->getMessage()); } } From 9be1b658f564a33579a2b3044c2ddd66ff3aa236 Mon Sep 17 00:00:00 2001 From: AreYouScared Date: Tue, 15 Oct 2019 18:28:46 -0400 Subject: [PATCH 06/16] MySQL 8 fix Fixes for users wanting to run MySQL v8+ --- .../migrations/2016_10_23_193810_add_foreign_keys_servers.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 '); } } From 1922db60dbdb5c44827cc92ed63a291dcabd0e0f Mon Sep 17 00:00:00 2001 From: AreYouScared Date: Mon, 21 Oct 2019 18:23:33 -0400 Subject: [PATCH 07/16] Update new.blade.php (#1732) --- resources/themes/pterodactyl/admin/nodes/new.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/themes/pterodactyl/admin/nodes/new.blade.php b/resources/themes/pterodactyl/admin/nodes/new.blade.php index 94ecb609f..eff033265 100644 --- a/resources/themes/pterodactyl/admin/nodes/new.blade.php +++ b/resources/themes/pterodactyl/admin/nodes/new.blade.php @@ -106,7 +106,7 @@
-
+

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.

@@ -177,4 +177,4 @@ -@endsection \ No newline at end of file +@endsection From c116c3392d777f26ef5f17b7d6662c80cb857527 Mon Sep 17 00:00:00 2001 From: AreYouScared Date: Tue, 22 Oct 2019 19:37:42 -0400 Subject: [PATCH 08/16] More uniformity More uniforminity within the egg page --- .../themes/pterodactyl/admin/eggs/scripts.blade.php | 9 +++++---- .../themes/pterodactyl/admin/eggs/variables.blade.php | 2 +- resources/themes/pterodactyl/admin/eggs/view.blade.php | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/resources/themes/pterodactyl/admin/eggs/scripts.blade.php b/resources/themes/pterodactyl/admin/eggs/scripts.blade.php index 55c6f1b9b..9b82b6d5d 100644 --- a/resources/themes/pterodactyl/admin/eggs/scripts.blade.php +++ b/resources/themes/pterodactyl/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') -

{{ $egg->name }}Manage install and upgrade scripts for this Egg.

+

{{ $egg->name }}Manage the install script for this Egg.

@endsection @@ -26,7 +27,7 @@
diff --git a/resources/themes/pterodactyl/admin/eggs/variables.blade.php b/resources/themes/pterodactyl/admin/eggs/variables.blade.php index f49886ee5..a01ea7133 100644 --- a/resources/themes/pterodactyl/admin/eggs/variables.blade.php +++ b/resources/themes/pterodactyl/admin/eggs/variables.blade.php @@ -27,7 +27,7 @@
diff --git a/resources/themes/pterodactyl/admin/eggs/view.blade.php b/resources/themes/pterodactyl/admin/eggs/view.blade.php index 715f749e0..64c3183e9 100644 --- a/resources/themes/pterodactyl/admin/eggs/view.blade.php +++ b/resources/themes/pterodactyl/admin/eggs/view.blade.php @@ -26,7 +26,7 @@ From 88c5bb4f97b94e6f5689825b3f2428798d6f9a3d Mon Sep 17 00:00:00 2001 From: Arnaud Lier Date: Mon, 11 Nov 2019 18:01:38 +0100 Subject: [PATCH 09/16] Added a return in DatabaseController when a error occurs (#1742) * Added a return in DatabaseController when a error occurs * add return on database update too --- app/Http/Controllers/Admin/DatabaseController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Admin/DatabaseController.php b/app/Http/Controllers/Admin/DatabaseController.php index 777b27792..4fecbbccf 100644 --- a/app/Http/Controllers/Admin/DatabaseController.php +++ b/app/Http/Controllers/Admin/DatabaseController.php @@ -131,7 +131,7 @@ class DatabaseController extends Controller sprintf('There was an error while trying to connect to the host or while executing a query: "%s"', $exception->getMessage()) )->flash(); - redirect()->route('admin.databases')->withInput($request->validated()); + return redirect()->route('admin.databases')->withInput($request->validated()); } else { throw $exception; } @@ -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; } From 5f60a6c73566764c5268f281288c141821b2c5e5 Mon Sep 17 00:00:00 2001 From: Stepan Fedotov Date: Sat, 28 Dec 2019 13:53:33 +0200 Subject: [PATCH 10/16] Fix the resource key for subusers --- app/Transformers/Api/Application/ServerTransformer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Transformers/Api/Application/ServerTransformer.php b/app/Transformers/Api/Application/ServerTransformer.php index 27e377e2d..70dc185d6 100644 --- a/app/Transformers/Api/Application/ServerTransformer.php +++ b/app/Transformers/Api/Application/ServerTransformer.php @@ -132,7 +132,7 @@ class ServerTransformer extends BaseTransformer $server->loadMissing('subusers'); - return $this->collection($server->getRelation('subusers'), $this->makeTransformer(SubuserTransformer::class), 'user'); + return $this->collection($server->getRelation('subusers'), $this->makeTransformer(SubuserTransformer::class), 'subuser'); } /** From 741ae27f18992968a4057419105220e33a301b36 Mon Sep 17 00:00:00 2001 From: Oreo Oreoniv <28255085+zKoz210@users.noreply.github.com> Date: Sat, 28 Dec 2019 22:10:39 +0300 Subject: [PATCH 11/16] Fixed TooManyLoginAttempts not work correctly (#1668) --- app/Http/Controllers/Auth/LoginController.php | 28 ++++++++++++------- config/auth.php | 2 +- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index c18b004b4..d5141c8d2 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -20,8 +20,6 @@ class LoginController extends Controller { use AuthenticatesUsers; - const USER_INPUT_FIELD = 'user'; - /** * @var \Illuminate\Auth\AuthManager */ @@ -64,14 +62,14 @@ class LoginController extends Controller * * @var int */ - protected $lockoutTime; + protected $decayMinutes; /** * After how many attempts should logins be throttled and locked. * * @var int */ - protected $maxLoginAttempts; + protected $maxAttempts; /** * LoginController constructor. @@ -98,8 +96,8 @@ class LoginController extends Controller $this->google2FA = $google2FA; $this->repository = $repository; - $this->lockoutTime = $this->config->get('auth.lockout.time'); - $this->maxLoginAttempts = $this->config->get('auth.lockout.attempts'); + $this->decayMinutes = $this->config->get('auth.lockout.time'); + $this->maxAttempts = $this->config->get('auth.lockout.attempts'); } /** @@ -112,7 +110,7 @@ class LoginController extends Controller */ public function login(Request $request) { - $username = $request->input(self::USER_INPUT_FIELD); + $username = $request->input($this->username()); $useColumn = $this->getField($username); if ($this->hasTooManyLoginAttempts($request)) { @@ -209,20 +207,30 @@ class LoginController extends Controller { $this->incrementLoginAttempts($request); $this->fireFailedLoginEvent($user, [ - $this->getField($request->input(self::USER_INPUT_FIELD)) => $request->input(self::USER_INPUT_FIELD), + $this->getField($request->input($this->username())) => $request->input($this->username()), ]); - $errors = [self::USER_INPUT_FIELD => trans('auth.failed')]; + $errors = [$this->username() => trans('auth.failed')]; if ($request->expectsJson()) { return response()->json($errors, 422); } return redirect()->route('auth.login') - ->withInput($request->only(self::USER_INPUT_FIELD)) + ->withInput($request->only($this->username())) ->withErrors($errors); } + /** + * Get the login username to be used by the controller. + * + * @return string + */ + public function username() + { + return 'user'; + } + /** * Determine if the user is logging in using an email or username,. * 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, ], From 86e6daf0aa8aab13b2ff0d3b7843a61baf991cad Mon Sep 17 00:00:00 2001 From: rtm516 Date: Sat, 28 Dec 2019 19:10:59 +0000 Subject: [PATCH 12/16] Update list.blade.php (#1674) --- resources/themes/pterodactyl/server/files/list.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/themes/pterodactyl/server/files/list.blade.php b/resources/themes/pterodactyl/server/files/list.blade.php index f8abc5a7b..e6a252e5f 100644 --- a/resources/themes/pterodactyl/server/files/list.blade.php +++ b/resources/themes/pterodactyl/server/files/list.blade.php @@ -141,7 +141,7 @@ @if(in_array($file['mime'], $editableMime)) @can('edit-files', $server) - {{ $file['entry'] }} + {{ $file['entry'] }} @else {{ $file['entry'] }} @endcan From c377be2a7c0fc7ba0581946b2d0578cecb0080cd Mon Sep 17 00:00:00 2001 From: Stepan Fedotov Date: Sat, 28 Dec 2019 21:12:01 +0200 Subject: [PATCH 13/16] Include the egg name in egg model's response from the application API (#1684) --- CHANGELOG.md | 4 ++++ app/Transformers/Api/Application/EggTransformer.php | 1 + 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22858333d..1d2edc870 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ 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) +### Added +* The application API now includes the egg's name in the egg model's response. + ## 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/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, From 34bf452bef3c537ef7928eabb7661054cee6d07f Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 28 Dec 2019 11:23:07 -0800 Subject: [PATCH 14/16] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 434234272..bacba59eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ 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. From 66ead2f682fab0235b63015bd4204f326b379498 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 28 Dec 2019 11:39:44 -0800 Subject: [PATCH 15/16] Update subuser API output to work correctly --- CHANGELOG.md | 2 +- app/Models/Server.php | 4 ++-- app/Transformers/Api/Application/SubuserTransformer.php | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bacba59eb..33749dd55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. ### 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 +* The /api/application/servers endpoint can now include server's databases and subusers. ## v0.7.15 (Derelict Dermodactylus) ### Fixed diff --git a/app/Models/Server.php b/app/Models/Server.php index 174453cfb..fd5d9d121 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -168,11 +168,11 @@ class Server extends Model implements CleansAttributes, ValidableContract /** * 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/Transformers/Api/Application/SubuserTransformer.php b/app/Transformers/Api/Application/SubuserTransformer.php index 1bb5d6017..7927272ca 100644 --- a/app/Transformers/Api/Application/SubuserTransformer.php +++ b/app/Transformers/Api/Application/SubuserTransformer.php @@ -3,6 +3,7 @@ namespace Pterodactyl\Transformers\Api\Application; use Pterodactyl\Models\Subuser; +use Pterodactyl\Models\Permission; use Pterodactyl\Services\Acl\Api\AdminAcl; class SubuserTransformer extends BaseTransformer @@ -34,7 +35,11 @@ class SubuserTransformer extends BaseTransformer { return [ 'id' => $subuser->id, - 'permissions' => $subuser->permissions->toArray(), + '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), ]; From 064d8e974e5f310759c8ee229e193d402702478c Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 28 Dec 2019 11:40:42 -0800 Subject: [PATCH 16/16] Bump for release --- config/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/app.php b/config/app.php index fccb8b888..7b4131709 100644 --- a/config/app.php +++ b/config/app.php @@ -9,7 +9,7 @@ return [ | change this value if you are not maintaining your own internal versions. */ - 'version' => 'canary', + 'version' => '0.7.16', /* |--------------------------------------------------------------------------