From 33555547048ade331f44af1f128183951f1e9a82 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 5 Mar 2017 16:46:44 -0500 Subject: [PATCH] Fix frontend database password reset --- .../Controllers/Server/AjaxController.php | 15 +++++----- public/themes/pterodactyl/css/pterodactyl.css | 2 +- .../server/settings/databases.blade.php | 28 ++++++++++--------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/app/Http/Controllers/Server/AjaxController.php b/app/Http/Controllers/Server/AjaxController.php index 8f3736da7..4609ae270 100644 --- a/app/Http/Controllers/Server/AjaxController.php +++ b/app/Http/Controllers/Server/AjaxController.php @@ -224,17 +224,16 @@ class AjaxController extends Controller $server = Models\Server::byUuid($uuid); $this->authorize('reset-db-password', $server); - $database = Models\Database::where('id', $request->input('database'))->where('server_id', $server->id)->firstOrFail(); + $database = Models\Database::where('server_id', $server->id)->findOrFail($request->input('database')); + $repo = new Repositories\DatabaseRepository; + try { - $repo = new Repositories\DatabaseRepository; - $password = str_random(16); - $repo->modifyPassword($request->input('database'), $password); + $password = str_random(20); + $repo->password($database->id, $password); return response($password); - } catch (\Pterodactyl\Exceptions\DisplayException $ex) { - return response()->json([ - 'error' => $ex->getMessage(), - ], 503); + } catch (DisplayException $ex) { + return response()->json(['error' => $ex->getMessage()], 503); } catch (\Exception $ex) { Log::error($ex); diff --git a/public/themes/pterodactyl/css/pterodactyl.css b/public/themes/pterodactyl/css/pterodactyl.css index c4b1cf256..ca34e46a5 100644 --- a/public/themes/pterodactyl/css/pterodactyl.css +++ b/public/themes/pterodactyl/css/pterodactyl.css @@ -65,7 +65,7 @@ code { font-size: 14px !important; } -.middle { +.middle, .align-middle { vertical-align: middle !important; } diff --git a/resources/themes/pterodactyl/server/settings/databases.blade.php b/resources/themes/pterodactyl/server/settings/databases.blade.php index b69b0f36d..5e90be84f 100644 --- a/resources/themes/pterodactyl/server/settings/databases.blade.php +++ b/resources/themes/pterodactyl/server/settings/databases.blade.php @@ -49,17 +49,19 @@ @lang('strings.username') @lang('strings.password') @lang('server.config.database.host') + @can('reset-db-password', $server)@endcan @foreach($databases as $database) - {{ $database->database }} - {{ $database->username }} - {{ Crypt::decrypt($database->password) }} - @can('reset-db-password', $server) - - @endcan - - {{ $database->a_host }}:{{ $database->a_port }} + {{ $database->database }} + {{ $database->username }} + {{ Crypt::decrypt($database->password) }} + {{ $database->a_host }}:{{ $database->a_port }} + @can('reset-db-password', $server) + + + + @endcan @endforeach @@ -88,10 +90,10 @@ {!! Theme::js('js/frontend/server.socket.js') !!}