diff --git a/app/Actions/Fortify/ResetUserPassword.php b/app/Actions/Fortify/ResetUserPassword.php
index fc47985cdd..58308b9a9f 100644
--- a/app/Actions/Fortify/ResetUserPassword.php
+++ b/app/Actions/Fortify/ResetUserPassword.php
@@ -61,5 +61,7 @@ public function reset(User $user, array $input): void
$user->active = true;
$user->save();
+
+ $user->passwordResetHistories()->create();
}
}
diff --git a/app/Actions/Fortify/UpdateUserPassword.php b/app/Actions/Fortify/UpdateUserPassword.php
index d6eb7a24b9..e913a4209b 100644
--- a/app/Actions/Fortify/UpdateUserPassword.php
+++ b/app/Actions/Fortify/UpdateUserPassword.php
@@ -42,5 +42,7 @@ public function update(User $user, array $input): void
$user->forceFill([
'password' => Hash::make($input['password']),
])->save();
+
+ $user->passwordResetHistories()->create();
}
}
diff --git a/app/Http/Controllers/Staff/PasswordResetHistoryController.php b/app/Http/Controllers/Staff/PasswordResetHistoryController.php
new file mode 100644
index 0000000000..3022d15ec4
--- /dev/null
+++ b/app/Http/Controllers/Staff/PasswordResetHistoryController.php
@@ -0,0 +1,30 @@
+
+ * @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
+ */
+
+namespace App\Http\Controllers\Staff;
+
+use App\Http\Controllers\Controller;
+
+class PasswordResetHistoryController extends Controller
+{
+ /**
+ * Display all user password reset histories.
+ */
+ public function index(): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ {
+ return view('Staff.password-reset-history.index');
+ }
+}
diff --git a/app/Http/Controllers/User/PasswordController.php b/app/Http/Controllers/User/PasswordController.php
index 11c8359f4e..3b2a91e722 100644
--- a/app/Http/Controllers/User/PasswordController.php
+++ b/app/Http/Controllers/User/PasswordController.php
@@ -19,6 +19,7 @@
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\Request;
+use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Password;
@@ -48,16 +49,21 @@ protected function update(Request $request, User $user): \Illuminate\Http\Redire
],
]);
- $user->update([
- 'password' => Hash::make($request->new_password),
- ]);
+ DB::transaction(function () use ($user, $request, $changedByStaff): void {
+ $user->update([
+ 'password' => Hash::make($request->new_password),
+ ]);
+
+ $user->passwordResetHistories()->create();
+
+ if ($changedByStaff) {
+ $user->sendSystemNotification(
+ subject: 'ATTENTION - Your password has been changed',
+ message: "Your password has been changed by staff. You will need to update your password manager with the new password.\n\nFor more information, please create a helpdesk ticket.",
+ );
+ }
+ });
- if ($changedByStaff) {
- $user->sendSystemNotification(
- subject: 'ATTENTION - Your password has been changed',
- message: "Your password has been changed by staff. You will need to update your password manager with the new password.\n\nFor more information, please create a helpdesk ticket.",
- );
- }
return to_route('users.password.edit', ['user' => $user])
->withSuccess('Your new password has been saved successfully.');
@@ -70,6 +76,9 @@ public function edit(Request $request, User $user): \Illuminate\Contracts\View\F
{
abort_unless($request->user()->is($user) || $request->user()->group->is_modo, 403);
- return view('user.password.edit', ['user' => $user]);
+ return view('user.password.edit', [
+ 'user' => $user,
+ 'passwordResetHistories' => $user->passwordResetHistories()->latest()->get(),
+ ]);
}
}
diff --git a/app/Http/Livewire/PasswordResetHistorySearch.php b/app/Http/Livewire/PasswordResetHistorySearch.php
new file mode 100644
index 0000000000..526aee9240
--- /dev/null
+++ b/app/Http/Livewire/PasswordResetHistorySearch.php
@@ -0,0 +1,66 @@
+
+ * @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
+ */
+
+namespace App\Http\Livewire;
+
+use App\Models\PasswordResetHistory;
+use App\Models\User;
+use App\Traits\LivewireSort;
+use Livewire\Attributes\Computed;
+use Livewire\Attributes\Url;
+use Livewire\Component;
+use Livewire\WithPagination;
+
+/**
+ * @property \Illuminate\Contracts\Pagination\LengthAwarePaginator
+ + + {{ __('user.password-resets') }} + +
+ {{ __('common.user') }} {{ __('user.password-resets') }} -
+ {{ __('staff.staff-dashboard') }} - {{ config('other.title') }}
+
+@endsection
+
+@section('meta')
+
+@endsection
+
+@section('breadcrumbs')
+ {{ __('user.password-resets') }}
+
+
+
+
+
+ @forelse ($passwordResetHistories as $passwordResetHistory)
+
+ {{ __('common.username') }}
+ @include('livewire.includes._sort-icon', ['field' => 'user_id'])
+
+
+ {{ __('common.created_at') }}
+ @include('livewire.includes._sort-icon', ['field' => 'created_at'])
+
+
+
+ @empty
+
+
+
+
+
+
+
+ @endforelse
+
+ No Password Resets
+ {{ __('user.password-resets') }}
+
+
+
+
+
+
+
+ @forelse ($passwordResetHistories as $passwordResetHistory)
+ {{ __('common.created_at') }}
+
+
+ @empty
+
+
+
+
+
+ @endforelse
+
+ No password reset history
+