Skip to content

Commit c9c0e84

Browse files
committed
Go nuclear on Safari's autocomplete.
1 parent b539f26 commit c9c0e84

File tree

7 files changed

+23
-38
lines changed

7 files changed

+23
-38
lines changed

app/Http/Controllers/Admin/UserController.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,12 @@ public function store(Request $request)
141141
*/
142142
public function update(Request $request, $id)
143143
{
144-
// Rename variables because autofill cannot be disabled
145-
// in any logical manner, and editing users is impossible.
146-
$fixedData = array_filter(
147-
collect($request->all())->mapWithKeys(function ($item, $key) {
148-
return [str_replace('input_', '', $key) => $item];
149-
})->only([
150-
'email', 'password', 'name_first',
151-
'name_last', 'username', 'root_admin',
152-
])->toArray()
153-
);
154-
155144
try {
156145
$repo = new UserRepository;
157-
$user = $repo->update($id, $fixedData);
146+
$user = $repo->update($id, $request->intersect([
147+
'email', 'password', 'name_first',
148+
'name_last', 'username', 'root_admin',
149+
]));
158150
Alert::success('User account was successfully updated.')->flash();
159151
} catch (DisplayValidationException $ex) {
160152
return redirect()->route('admin.users.view', $id)->withErrors(json_decode($ex->getMessage()));

public/js/autocomplete.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Hacky fix for browsers ignoring autocomplete="off"
2+
$(document).ready(function() {
3+
$('.form-autocomplete-stop').on('click', function () {
4+
$(this).removeAttr('readonly').blur().focus();
5+
});
6+
});

public/themes/pterodactyl/css/pterodactyl.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,8 @@ tr:hover + tr.server-description {
299299
bottom: 5px;
300300
right: 10px;
301301
}
302+
303+
input.form-autocomplete-stop[readonly] {
304+
background: inherit;
305+
cursor: text;
306+
}

resources/themes/pterodactyl/admin/users/view.blade.php

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,25 @@
4444
<div class="form-group">
4545
<label for="email" class="control-label">Email</label>
4646
<div>
47-
<input type="email" name="input_email" value="{{ $user->email }}" class="form-control">
47+
<input readonly type="email" name="email" value="{{ $user->email }}" class="form-control form-autocomplete-stop">
4848
</div>
4949
</div>
5050
<div class="form-group">
5151
<label for="registered" class="control-label">Username</label>
5252
<div>
53-
<input type="text" name="input_username" value="{{ $user->username }}" class="form-control">
53+
<input readonly type="text" name="username" value="{{ $user->username }}" class="form-control form-autocomplete-stop">
5454
</div>
5555
</div>
5656
<div class="form-group">
5757
<label for="registered" class="control-label">Client First Name</label>
5858
<div>
59-
<input type="text" name="name_first" value="{{ $user->name_first }}" class="form-control">
59+
<input readonly type="text" name="name_first" value="{{ $user->name_first }}" class="form-control form-autocomplete-stop">
6060
</div>
6161
</div>
6262
<div class="form-group">
6363
<label for="registered" class="control-label">Client Last Name</label>
6464
<div>
65-
<input type="text" name="name_last" value="{{ $user->name_last }}" class="form-control">
65+
<input readonly type="text" name="name_last" value="{{ $user->name_last }}" class="form-control form-autocomplete-stop">
6666
</div>
6767
</div>
6868
</div>
@@ -82,7 +82,7 @@
8282
<div class="form-group">
8383
<label for="password" class="control-label">Password</label>
8484
<div>
85-
<input type="password" id="password" name="input_password" class="form-control">
85+
<input readonly type="password" id="password" name="password" class="form-control form-autocomplete-stop">
8686
</div>
8787
</div>
8888
</div>
@@ -167,24 +167,3 @@
167167
</div>
168168
</div>
169169
@endsection
170-
171-
@section('footer-scripts')
172-
@parent
173-
<script>$("#gen_pass_bttn").click(function (event) {
174-
event.preventDefault();
175-
$.ajax({
176-
type: "GET",
177-
url: "/password-gen/12",
178-
headers: {
179-
'X-CSRF-TOKEN': '{{ csrf_token() }}'
180-
},
181-
success: function(data) {
182-
$("#gen_pass").html('You must click <em>Update Password</em> below for this password to be applied.<br /><br /><strong>Generated Password:</strong> ' + data).slideDown();
183-
$('input[name="password"], input[name="password_confirmation"]').val(data);
184-
return false;
185-
}
186-
});
187-
return false;
188-
});
189-
</script>
190-
@endsection

resources/themes/pterodactyl/layouts/admin.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@
190190
{!! Theme::js('vendor/bootstrap-notify/bootstrap-notify.min.js') !!}
191191
{!! Theme::js('vendor/select2/select2.full.min.js') !!}
192192
{!! Theme::js('js/admin/functions.js') !!}
193+
{!! Theme::js('js/autocomplete.js') !!}
193194
@show
194195
</body>
195196
</html>

resources/themes/pterodactyl/layouts/auth.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
</div>
6464
{!! Theme::js('vendor/jquery/jquery.min.js') !!}
6565
{!! Theme::js('vendor/bootstrap/bootstrap.min.js') !!}
66+
{!! Theme::js('js/autocomplete.js') !!}
6667

6768
@if(config('pterodactyl.lang.in_context')) {!! Theme::js('vendor/phraseapp/phraseapp.js') !!} @endif
6869
</body>

resources/themes/pterodactyl/layouts/master.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ class="active"
279279
{!! Theme::js('vendor/adminlte/app.min.js') !!}
280280
{!! Theme::js('vendor/socketio/socket.io.min.js') !!}
281281
{!! Theme::js('vendor/bootstrap-notify/bootstrap-notify.min.js') !!}
282+
{!! Theme::js('js/autocomplete.js') !!}
282283
@if(config('pterodactyl.lang.in_context'))
283284
{!! Theme::js('vendor/phraseapp/phraseapp.js') !!}
284285
@endif

0 commit comments

Comments
 (0)