diff --git a/app/Actions/Fortify/ResetUserPassword.php b/app/Actions/Fortify/ResetUserPassword.php index 8b0eb37..cbbfb31 100644 --- a/app/Actions/Fortify/ResetUserPassword.php +++ b/app/Actions/Fortify/ResetUserPassword.php @@ -29,7 +29,7 @@ class ResetUserPassword implements ResetsUserPasswords AuditLogEntry::create([ 'user' => $user->email, 'ip_address' => request()->ip(), - 'message' => 'Reset Password', + 'message' => 'Changed password for '.$user->email.' ('.$user->full_name().')', 'affected' => ['users' => [$user->id]], ]); } diff --git a/tests/Feature/app/Actions/Fortify/ResetUserPasswordTest.php b/tests/Feature/app/Actions/Fortify/ResetUserPasswordTest.php new file mode 100644 index 0000000..331e67a --- /dev/null +++ b/tests/Feature/app/Actions/Fortify/ResetUserPasswordTest.php @@ -0,0 +1,25 @@ +user = User::factory()->create(); +}); + +it('resets a user password', function () { + $changer = app(ResetUserPassword::class); + $changer->reset($this->user, ['password' => 'password123', 'password_confirmation' => 'password123']); + $this->user->refresh(); + expect(\Illuminate\Support\Facades\Hash::check('password123', $this->user->password))->toBeTrue(); +}); + +it('logs password change', function () { + $changer = app(ResetUserPassword::class); + $changer->reset($this->user, ['password' => 'password123', 'password_confirmation' => 'password123']); + $logEntry = \App\Models\AuditLogEntry::first(); + expect($logEntry->message)->toEqual('Changed password for '.$this->user->email.' ('.$this->user->full_name().')'); +});