From c9c0e845b1700c59da5c11a8fbbfcc988a6a899b Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Mon, 1 May 2017 16:41:39 -0400 Subject: [PATCH] Go nuclear on Safari's autocomplete. --- app/Http/Controllers/Admin/UserController.php | 16 +++------- public/js/autocomplete.js | 6 ++++ public/themes/pterodactyl/css/pterodactyl.css | 5 +++ .../pterodactyl/admin/users/view.blade.php | 31 +++---------------- .../pterodactyl/layouts/admin.blade.php | 1 + .../themes/pterodactyl/layouts/auth.blade.php | 1 + .../pterodactyl/layouts/master.blade.php | 1 + 7 files changed, 23 insertions(+), 38 deletions(-) create mode 100644 public/js/autocomplete.js diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 2822cb3c4..c9d7a4725 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -141,20 +141,12 @@ class UserController extends Controller */ public function update(Request $request, $id) { - // Rename variables because autofill cannot be disabled - // in any logical manner, and editing users is impossible. - $fixedData = array_filter( - collect($request->all())->mapWithKeys(function ($item, $key) { - return [str_replace('input_', '', $key) => $item]; - })->only([ - 'email', 'password', 'name_first', - 'name_last', 'username', 'root_admin', - ])->toArray() - ); - try { $repo = new UserRepository; - $user = $repo->update($id, $fixedData); + $user = $repo->update($id, $request->intersect([ + 'email', 'password', 'name_first', + 'name_last', 'username', 'root_admin', + ])); Alert::success('User account was successfully updated.')->flash(); } catch (DisplayValidationException $ex) { return redirect()->route('admin.users.view', $id)->withErrors(json_decode($ex->getMessage())); diff --git a/public/js/autocomplete.js b/public/js/autocomplete.js new file mode 100644 index 000000000..15c43797e --- /dev/null +++ b/public/js/autocomplete.js @@ -0,0 +1,6 @@ +// Hacky fix for browsers ignoring autocomplete="off" +$(document).ready(function() { + $('.form-autocomplete-stop').on('click', function () { + $(this).removeAttr('readonly').blur().focus(); + }); +}); diff --git a/public/themes/pterodactyl/css/pterodactyl.css b/public/themes/pterodactyl/css/pterodactyl.css index 9c4f69c44..96a7f030e 100644 --- a/public/themes/pterodactyl/css/pterodactyl.css +++ b/public/themes/pterodactyl/css/pterodactyl.css @@ -299,3 +299,8 @@ tr:hover + tr.server-description { bottom: 5px; right: 10px; } + +input.form-autocomplete-stop[readonly] { + background: inherit; + cursor: text; +} diff --git a/resources/themes/pterodactyl/admin/users/view.blade.php b/resources/themes/pterodactyl/admin/users/view.blade.php index 3580b0dd3..39461e462 100644 --- a/resources/themes/pterodactyl/admin/users/view.blade.php +++ b/resources/themes/pterodactyl/admin/users/view.blade.php @@ -44,25 +44,25 @@
- +
- +
- +
- +
@@ -82,7 +82,7 @@
- +
@@ -167,24 +167,3 @@ @endsection - -@section('footer-scripts') - @parent - -@endsection diff --git a/resources/themes/pterodactyl/layouts/admin.blade.php b/resources/themes/pterodactyl/layouts/admin.blade.php index 7d140fa87..d546576ee 100644 --- a/resources/themes/pterodactyl/layouts/admin.blade.php +++ b/resources/themes/pterodactyl/layouts/admin.blade.php @@ -190,6 +190,7 @@ {!! Theme::js('vendor/bootstrap-notify/bootstrap-notify.min.js') !!} {!! Theme::js('vendor/select2/select2.full.min.js') !!} {!! Theme::js('js/admin/functions.js') !!} + {!! Theme::js('js/autocomplete.js') !!} @show diff --git a/resources/themes/pterodactyl/layouts/auth.blade.php b/resources/themes/pterodactyl/layouts/auth.blade.php index 920c399f1..1d9631fd8 100644 --- a/resources/themes/pterodactyl/layouts/auth.blade.php +++ b/resources/themes/pterodactyl/layouts/auth.blade.php @@ -63,6 +63,7 @@ {!! Theme::js('vendor/jquery/jquery.min.js') !!} {!! Theme::js('vendor/bootstrap/bootstrap.min.js') !!} + {!! Theme::js('js/autocomplete.js') !!} @if(config('pterodactyl.lang.in_context')) {!! Theme::js('vendor/phraseapp/phraseapp.js') !!} @endif diff --git a/resources/themes/pterodactyl/layouts/master.blade.php b/resources/themes/pterodactyl/layouts/master.blade.php index fc6656c6d..9620faa02 100644 --- a/resources/themes/pterodactyl/layouts/master.blade.php +++ b/resources/themes/pterodactyl/layouts/master.blade.php @@ -279,6 +279,7 @@ {!! Theme::js('vendor/adminlte/app.min.js') !!} {!! Theme::js('vendor/socketio/socket.io.min.js') !!} {!! Theme::js('vendor/bootstrap-notify/bootstrap-notify.min.js') !!} + {!! Theme::js('js/autocomplete.js') !!} @if(config('pterodactyl.lang.in_context')) {!! Theme::js('vendor/phraseapp/phraseapp.js') !!} @endif