Skip to content

Commit

Permalink
Fix some issues with admin self settings (librenms#15332)
Browse files Browse the repository at this point in the history
Don't require old password when not settings password
Show old password field for user's own user
  • Loading branch information
murrant authored Sep 18, 2023
1 parent 1bf68f7 commit 35406b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/Http/Requests/UpdateUserRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public function withValidator($validator)
// 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'));
Expand Down
4 changes: 2 additions & 2 deletions resources/views/user/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down

0 comments on commit 35406b4

Please sign in to comment.