From 8b4bd3945da0638d29b9d444418b6c1452e011bd Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 13 Sep 2020 12:35:48 -0700 Subject: [PATCH] Fix user search in admin area; closes #2100 --- app/Http/Controllers/Admin/UserController.php | 13 +++++++++++-- public/themes/pterodactyl/js/admin/new-server.js | 2 +- resources/views/admin/nodes/index.blade.php | 2 +- resources/views/admin/servers/new.blade.php | 2 +- .../views/admin/servers/view/details.blade.php | 2 +- resources/views/admin/users/index.blade.php | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index f6d9a4c3b..2afbe1407 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -185,11 +185,20 @@ class UserController extends Controller */ public function json(Request $request) { + $users = QueryBuilder::for(User::query())->allowedFilters(['email'])->paginate(25); + // Handle single user requests. if ($request->query('user_id')) { - return $this->repository->filterById($request->input('user_id')); + $user = User::query()->findOrFail($request->input('user_id')); + $user->md5 = md5(strtolower($user->email)); + + return $user; } - return $this->repository->filterUsersByQuery($request->input('q')); + return $users->map(function ($item) { + $item->md5 = md5(strtolower($item->email)); + + return $item; + }); } } diff --git a/public/themes/pterodactyl/js/admin/new-server.js b/public/themes/pterodactyl/js/admin/new-server.js index 3e0718a46..7416451da 100644 --- a/public/themes/pterodactyl/js/admin/new-server.js +++ b/public/themes/pterodactyl/js/admin/new-server.js @@ -161,7 +161,7 @@ function initUserIdSelect(data) { data: function (params) { return { - q: params.term, // search term + filter: { email: params.term }, page: params.page, }; }, diff --git a/resources/views/admin/nodes/index.blade.php b/resources/views/admin/nodes/index.blade.php index a8de9554d..524d81107 100644 --- a/resources/views/admin/nodes/index.blade.php +++ b/resources/views/admin/nodes/index.blade.php @@ -31,7 +31,7 @@
- +
diff --git a/resources/views/admin/servers/new.blade.php b/resources/views/admin/servers/new.blade.php index fe9c7be24..47f6d06ba 100644 --- a/resources/views/admin/servers/new.blade.php +++ b/resources/views/admin/servers/new.blade.php @@ -327,7 +327,7 @@ // END Persist 'Service Variables' - {!! Theme::js('js/admin/new-server.js') !!} + {!! Theme::js('js/admin/new-server.js?v=20200913') !!}