Fixed 'Edit User' changes not applying
Fixed bug where if a user was edited on the Admin Panel under 'Admin>Users> Edit User' changes would not apply without every value being changed. This bug originates from LittleLink Admin (the fork of which this fork is based on). One part of this issue was that most fields were required to fill in. If only one would be left, empty, none would apply. The problem was if this requirement was removed, the password would always overwrite the current password, even when left empty. This meant you could only edit users if you knew their password, otherwise their passwords would be changed, probably preventing that user from login in ever again. After some experimenting, I implemented the easiest fix I could come up with. A simple if-else statement that checks if the password field is empty and if so only saves the other parameters without touching the password. If the password is changed, the changes will be applied normally. Also fixed the profile image size for the default placeholder image.
This commit is contained in:
parent
89479791de
commit
cf66be63cb
|
@ -98,10 +98,10 @@ class AdminController extends Controller
|
||||||
public function editUser(request $request)
|
public function editUser(request $request)
|
||||||
{
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'name' => 'required',
|
'name' => '',
|
||||||
'email' => 'required',
|
'email' => '',
|
||||||
'password' => 'required',
|
'password' => '',
|
||||||
'littlelink_name' => 'required',
|
'littlelink_name' => '',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$id = $request->id;
|
$id = $request->id;
|
||||||
|
@ -113,8 +113,11 @@ class AdminController extends Controller
|
||||||
$littlelink_description = $request->littlelink_description;
|
$littlelink_description = $request->littlelink_description;
|
||||||
$role = $request->role;
|
$role = $request->role;
|
||||||
|
|
||||||
|
if($request->password == '' ) {
|
||||||
|
User::where('id', $id)->update(['name' => $name, 'email' => $email, 'littlelink_name' => $littlelink_name, 'littlelink_description' => $littlelink_description, 'role' => $role]);
|
||||||
|
} else {
|
||||||
User::where('id', $id)->update(['name' => $name, 'email' => $email, 'password' => $password, 'littlelink_name' => $littlelink_name, 'littlelink_description' => $littlelink_description, 'role' => $role]);
|
User::where('id', $id)->update(['name' => $name, 'email' => $email, 'password' => $password, 'littlelink_name' => $littlelink_name, 'littlelink_description' => $littlelink_description, 'role' => $role]);
|
||||||
|
}
|
||||||
if(!empty($profilePhoto)){
|
if(!empty($profilePhoto)){
|
||||||
$profilePhoto->move(base_path('/img'), $littlelink_name . ".png");
|
$profilePhoto->move(base_path('/img'), $littlelink_name . ".png");
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-lg-8">
|
<div class="form-group col-lg-8">
|
||||||
<label>Password</label>
|
<label>Password</label>
|
||||||
<input type="password" class="form-control" name="password" placeholder="if empty, password will blank">
|
<input type="password" class="form-control" name="password" placeholder="Leave empty for no change">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-lg-8">
|
<div class="form-group col-lg-8">
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
@elseif(file_exists(base_path("littlelink/images/avatar.png" )))
|
@elseif(file_exists(base_path("littlelink/images/avatar.png" )))
|
||||||
<img class="rounded-avatar" src="{{ asset('littlelink/images/avatar.png') }}" srcset="{{ asset('littlelink/images/avatar@2x.png 2x') }}" width="100px" height="100px">
|
<img class="rounded-avatar" src="{{ asset('littlelink/images/avatar.png') }}" srcset="{{ asset('littlelink/images/avatar@2x.png 2x') }}" width="100px" height="100px">
|
||||||
@else
|
@else
|
||||||
<img src="{{ asset('littlelink/images/logo.svg') }}" srcset="{{ asset('littlelink/images/avatar@2x.png 2x') }}">
|
<img src="{{ asset('littlelink/images/logo.svg') }}" srcset="{{ asset('littlelink/images/avatar@2x.png 2x') }}" width="100px" height="100px">
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -56,9 +56,9 @@
|
||||||
<div class="form-group col-lg-8">
|
<div class="form-group col-lg-8">
|
||||||
<label for="exampleFormControlSelect1">Role</label>
|
<label for="exampleFormControlSelect1">Role</label>
|
||||||
<select class="form-control" name="role">
|
<select class="form-control" name="role">
|
||||||
<option <?= ($user->role === strtolower('User')) ? 'selected' : '' ?>>User</option>
|
<option <?= ($user->role === strtolower('user')) ? 'selected' : '' ?>>user</option>
|
||||||
<option <?= ($user->role === strtolower('VIP')) ? 'selected' : '' ?>>VIP</option>
|
<option <?= ($user->role === strtolower('vip')) ? 'selected' : '' ?>>vip</option>
|
||||||
<option <?= ($user->role === strtolower('Admin')) ? 'selected' : '' ?>>Admin</option>
|
<option <?= ($user->role === strtolower('admin')) ? 'selected' : '' ?>>admin</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
Loading…
Reference in New Issue