From 8771597560e0feec988960d80be3cba93d666f47 Mon Sep 17 00:00:00 2001 From: DaneEveritt Date: Sun, 5 Jun 2022 13:28:46 -0400 Subject: [PATCH] Fix database deletion; closes #4114 Co-Authored-By: Dawid --- CHANGELOG.md | 5 ++++ .../Controllers/Admin/ServersController.php | 25 +++++-------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aacb4184d..6566871d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ 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. +## v1.8.2 +### Fixed +* Fixes a bug causing a 404 error when attempting to delete a database from a server in the admin control panel. +* Fixes console input auto-capitalizing and auto-correcting when entering text on some mobile devices. + ## v1.8.1 ### Fixed * Fixes a bug causing mounts to return a 404 error when adding them to a server. diff --git a/app/Http/Controllers/Admin/ServersController.php b/app/Http/Controllers/Admin/ServersController.php index a12d00444..bb36afa18 100644 --- a/app/Http/Controllers/Admin/ServersController.php +++ b/app/Http/Controllers/Admin/ServersController.php @@ -13,6 +13,7 @@ use Illuminate\Http\Request; use Pterodactyl\Models\User; use Pterodactyl\Models\Mount; use Pterodactyl\Models\Server; +use Pterodactyl\Models\Database; use Pterodactyl\Models\MountServer; use Prologue\Alerts\AlertsMessageBag; use Pterodactyl\Exceptions\DisplayException; @@ -344,18 +345,13 @@ class ServersController extends Controller /** * Resets the database password for a specific database on this server. * - * @param int $server - * - * @return \Illuminate\Http\RedirectResponse + * @return \Illuminate\Http\Response * * @throws \Throwable */ - public function resetDatabasePassword(Request $request, $server) + public function resetDatabasePassword(Request $request, Server $server) { - $database = $this->databaseRepository->findFirstWhere([ - ['server_id', '=', $server], - ['id', '=', $request->input('database')], - ]); + $database = $server->databases()->where('id', $request->input('database'))->findOrFail(); $this->databasePasswordService->handle($database); @@ -365,21 +361,12 @@ class ServersController extends Controller /** * Deletes a database from a server. * - * @param int $server - * @param int $database - * - * @return \Illuminate\Http\RedirectResponse + * @return \Illuminate\Http\Response * * @throws \Exception - * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ - public function deleteDatabase($server, $database) + public function deleteDatabase(Server $server, Database $database) { - $database = $this->databaseRepository->findFirstWhere([ - ['server_id', '=', $server], - ['id', '=', $database], - ]); - $this->databaseManagementService->delete($database); return response('', 204);