Added ability to trigger forgotten password emails for users

This commit is contained in:
snipe 2018-07-30 20:30:47 -07:00
parent c2bb3892b7
commit 006a3adea0
2 changed files with 23 additions and 1 deletions

View file

@ -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
}
}
}

View file

@ -50,6 +50,7 @@
<select name="bulk_actions" class="form-control select2" style="width: 200px;">
<option value="delete">Bulk Checkin &amp; Delete</option>
<option value="edit">Bulk Edit</option>
<option value="bulkpasswordreset">Send Password Reset</option>
</select>
<button class="btn btn-default" id="bulkEdit" disabled>Go</button>
</div>