From 006a3adea03601cc1cc2140fe05a4386e6f0eecf Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 30 Jul 2018 20:30:47 -0700 Subject: [PATCH] Added ability to trigger forgotten password emails for users --- .../Controllers/Users/BulkUsersController.php | 23 ++++++++++++++++++- resources/views/users/index.blade.php | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Users/BulkUsersController.php b/app/Http/Controllers/Users/BulkUsersController.php index 6fd397878b..0635c74117 100644 --- a/app/Http/Controllers/Users/BulkUsersController.php +++ b/app/Http/Controllers/Users/BulkUsersController.php @@ -13,6 +13,7 @@ use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Password; class BulkUsersController extends Controller { @@ -34,11 +35,29 @@ class BulkUsersController extends Controller $statuslabel_list = Helper::statusLabelList(); $users = User::whereIn('id', array_keys(request('ids'))) ->with('groups', 'assets', 'licenses', 'accessories')->get(); + if ($request->input('bulk_actions') == 'edit') { return view('users/bulk-edit', compact('users')) ->with('groups', Group::pluck('name', 'id')); + + } elseif ($request->input('bulk_actions') == 'delete') { + return view('users/confirm-bulk-delete', compact('users', 'statuslabel_list')); + + } elseif ($request->input('bulk_actions') == 'bulkpasswordreset') { + if ($users) { + foreach ($users as $user) { + if ($user->email!='') { + $credentials = ['email' => $user->email]; + Password::sendResetLink($credentials, function (Message $message) { + $message->subject($this->getEmailSubject()); + }); + } + } + } + return redirect()->back()->with('success', 'The selected users with email addresses have been sent a password reset link.'); + } - return view('users/confirm-bulk-delete', compact('users', 'statuslabel_list')); + } return redirect()->back()->with('error', 'No users selected'); @@ -201,4 +220,6 @@ class BulkUsersController extends Controller } } + + } diff --git a/resources/views/users/index.blade.php b/resources/views/users/index.blade.php index 1ad0c4af7a..ab9e776a9b 100755 --- a/resources/views/users/index.blade.php +++ b/resources/views/users/index.blade.php @@ -50,6 +50,7 @@