Fix some issues with admin self settings (#15332)

Don't require old password when not settings password
Show old password field for user's own user
This commit is contained in:
Tony Murray 2023-09-18 14:35:12 -05:00 committed by GitHub
parent 1bf68f73c4
commit 35406b4b32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -81,8 +81,8 @@ class UpdateUserRequest extends FormRequest
// if not an admin and new_password is set, check old password matches
$user = $this->route('user');
if ($user && $this->user()->can('update', $user) && $this->user()->is($user)) {
if ($this->has('new_password')) {
if ($this->has('old_password')) {
if ($this->get('new_password')) {
if ($this->get('old_password')) {
$user = $this->route('user');
if ($user && ! Hash::check($this->old_password, $user->password)) {
$validator->errors()->add('old_password', __('Existing password did not match'));

View File

@ -60,9 +60,9 @@
<div class="form-group @if($errors->hasAny(['old_password', 'new_password', 'new_password_confirmation'])) has-error @endif">
<label for="password" class="control-label col-sm-3">{{ __('Password') }}</label>
<div class="col-sm-9">
@cannot('admin')
@if(auth()->user()->cannot('admin') || auth()->user()->is($user))
<input type="password" class="form-control" id="old_password" name="old_password" placeholder="{{ __('Current Password') }}">
@endcannot
@endif
<input type="password" autocomplete="off" class="form-control" id="new_password" name="new_password" placeholder="{{ __('New Password') }}">
<input type="password" autocomplete="off" class="form-control" id="new_password_confirmation" name="new_password_confirmation" placeholder="{{ __('Confirm Password') }}">
<span class="help-block">