Stop browser autofill on user view pages.

This commit is contained in:
Dane Everitt 2017-05-01 16:17:31 -04:00
parent 6dc1c15739
commit b539f26dab
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 15 additions and 7 deletions

View file

@ -141,12 +141,20 @@ class UserController extends Controller
*/
public function update(Request $request, $id)
{
try {
$repo = new UserRepository;
$user = $repo->update($id, $request->intersect([
// 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);
Alert::success('User account was successfully updated.')->flash();
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.users.view', $id)->withErrors(json_decode($ex->getMessage()));

View file

@ -44,13 +44,13 @@
<div class="form-group">
<label for="email" class="control-label">Email</label>
<div>
<input type="text" name="email" value="{{ $user->email }}" class="form-control">
<input type="email" name="input_email" value="{{ $user->email }}" class="form-control">
</div>
</div>
<div class="form-group">
<label for="registered" class="control-label">Username</label>
<div>
<input type="text" name="username" value="{{ $user->username }}" class="form-control">
<input type="text" name="input_username" value="{{ $user->username }}" class="form-control">
</div>
</div>
<div class="form-group">
@ -82,7 +82,7 @@
<div class="form-group">
<label for="password" class="control-label">Password</label>
<div>
<input type="password" id="password" name="password" class="form-control">
<input type="password" id="password" name="input_password" class="form-control">
</div>
</div>
</div>