diff --git a/CHANGELOG.md b/CHANGELOG.md index fe758d3b9..b98009245 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. * Fixes an issue with the sidebar logo not working correctly in some browsers due to the CSS being assigned. * Fixes a bunch of typos through the code base. * Fixes a bug when attempting to load the dropdown menu for server owner in some cases. +* Fixes an exception thrown when the database connection address was not filled out correctly while adding a database to a server. ### Added * Added a new client API endpoint for gathering the utilization stats for servers including disk, cpu, and memory. `GET /api/client/servers//utilization` diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php index d2396236e..fc19606f5 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -35,6 +35,7 @@ use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface; use Pterodactyl\Contracts\Repository\LocationRepositoryInterface; use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface; +use Pterodactyl\Http\Requests\Admin\Servers\Databases\StoreServerDatabaseRequest; class ServersController extends Controller { @@ -537,7 +538,7 @@ class ServersController extends Controller /** * Update the startup command as well as variables. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request * @param \Pterodactyl\Models\Server $server * @return \Illuminate\Http\RedirectResponse * @@ -558,15 +559,13 @@ class ServersController extends Controller /** * Creates a new database assigned to a specific server. * - * @param \Illuminate\Http\Request $request - * @param int $server + * @param \Pterodactyl\Http\Requests\Admin\Servers\Databases\StoreServerDatabaseRequest $request + * @param int $server * @return \Illuminate\Http\RedirectResponse * * @throws \Exception - * @throws \Pterodactyl\Exceptions\DisplayException - * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ - public function newDatabase(Request $request, $server) + public function newDatabase(StoreServerDatabaseRequest $request, $server) { $this->databaseManagementService->create($server, [ 'database' => $request->input('database'), diff --git a/app/Http/Controllers/Api/Application/Servers/DatabaseController.php b/app/Http/Controllers/Api/Application/Servers/DatabaseController.php index 05512a4ee..ce86cc4d7 100644 --- a/app/Http/Controllers/Api/Application/Servers/DatabaseController.php +++ b/app/Http/Controllers/Api/Application/Servers/DatabaseController.php @@ -104,8 +104,6 @@ class DatabaseController extends ApplicationApiController * @return \Illuminate\Http\JsonResponse * * @throws \Exception - * @throws \Pterodactyl\Exceptions\DisplayException - * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ public function store(StoreServerDatabaseRequest $request): JsonResponse { diff --git a/app/Http/Requests/Admin/Servers/Databases/StoreServerDatabaseRequest.php b/app/Http/Requests/Admin/Servers/Databases/StoreServerDatabaseRequest.php new file mode 100644 index 000000000..7f08ecd08 --- /dev/null +++ b/app/Http/Requests/Admin/Servers/Databases/StoreServerDatabaseRequest.php @@ -0,0 +1,22 @@ + 'required|string|min:1|max:24', + 'remote' => 'required|string|regex:/^[0-9%.]{1,15}$/', + 'database_host_id' => 'required|integer|exists:database_hosts,id', + ]; + } +} diff --git a/app/Http/Requests/Api/Application/Servers/Databases/StoreServerDatabaseRequest.php b/app/Http/Requests/Api/Application/Servers/Databases/StoreServerDatabaseRequest.php index 5a199b80e..ee4264a9d 100644 --- a/app/Http/Requests/Api/Application/Servers/Databases/StoreServerDatabaseRequest.php +++ b/app/Http/Requests/Api/Application/Servers/Databases/StoreServerDatabaseRequest.php @@ -26,7 +26,7 @@ class StoreServerDatabaseRequest extends ApplicationApiRequest { return [ 'database' => 'required|string|min:1|max:24', - 'remote' => 'required|string|min:1', + 'remote' => 'required|string|regex:/^[0-9%.]{1,15}$/', 'host' => 'required|integer|exists:database_hosts,id', ]; }