diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index bfba9b26f7..227260369e 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -15,6 +15,7 @@ use App\Models\User; use App\Notifications\WelcomeNotification; use Auth; use Illuminate\Database\Eloquent\ModelNotFoundException; +use Illuminate\Support\Facades\Password; use Input; use Redirect; use Str; @@ -617,4 +618,31 @@ class UsersController extends Controller ->with('show_user', $show_user) ->with('settings', Setting::getSettings()); } + + + /** + * Send individual password reset email + * + * @author A. Gianotto + * @since [v5.0.15] + * @return \Illuminate\Http\RedirectResponse + */ + public function sendPasswordReset($id) { + + if (($user = User::find($id)) && ($user->activated == '1') && ($user->email!='') && ($user->ldap_import == '0')) { + $credentials = ['email' => $user->email]; + + try { + \Password::sendResetLink($credentials, function (Message $message) use ($user) { + $message->subject($this->getEmailSubject()); + }); + return redirect()->back()->with('success', trans('admin/users/message.password_reset_sent', ['email' => $user->email])); + + } catch (\Exception $e) { + return redirect()->back()->with('error', ' Error sending email. :( '); + } + + } + return redirect()->back()->with('error', 'User is not activated, is LDAP synced, or does not have an email address '); + } } diff --git a/resources/lang/en/admin/users/message.php b/resources/lang/en/admin/users/message.php index 65a75b08c2..874ab9e901 100644 --- a/resources/lang/en/admin/users/message.php +++ b/resources/lang/en/admin/users/message.php @@ -13,6 +13,8 @@ return array( 'user_deleted_warning' => 'This user has been deleted. You will have to restore this user to edit them or assign them new assets.', 'ldap_not_configured' => 'LDAP integration has not been configured for this installation.', 'password_resets_sent' => 'The selected users who are activated and have a valid email addresses have been sent a password reset link.', + 'password_reset_sent' => 'A password reset link has been sent to :email!', + 'success' => array( diff --git a/resources/lang/en/button.php b/resources/lang/en/button.php index 2b97223250..27131e5fc6 100644 --- a/resources/lang/en/button.php +++ b/resources/lang/en/button.php @@ -14,4 +14,5 @@ return array( 'select_file' => 'Select File...', 'select_files' => 'Select Files...', 'generate_labels' => '{1} Generate Label|[2,*] Generate Labels', + 'send_password_link' => 'Send Password Reset Link', ); diff --git a/resources/views/users/index.blade.php b/resources/views/users/index.blade.php index bd4bad5046..9c1e90fc05 100755 --- a/resources/views/users/index.blade.php +++ b/resources/views/users/index.blade.php @@ -52,6 +52,7 @@ diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.php index 4cbbe99381..f94ec9e004 100755 --- a/resources/views/users/view.blade.php +++ b/resources/views/users/view.blade.php @@ -128,7 +128,7 @@ @endif -
+
@if (!is_null($user->company)) @@ -326,7 +326,7 @@ -
+
@can('update', $user) @endcan + + @can('update', $user) + @if (($user->activated == '1') && ($user->email != '') && ($user->ldap_import == '0')) +
+
+ {{ csrf_field() }} + + +
+ @endif + @endcan + @can('delete', $user) @if ($user->deleted_at=='') -
+
{{csrf_field()}} {{ method_field("DELETE")}} diff --git a/routes/web/users.php b/routes/web/users.php index f1927c1604..fd0ef77158 100644 --- a/routes/web/users.php +++ b/routes/web/users.php @@ -16,6 +16,16 @@ Route::group([ 'prefix' => 'users', 'middleware' => ['auth']], function () { [ 'as' => 'userfile.destroy', 'uses' => 'Users\UserFilesController@destroy' ] ); + + Route::post( + '{userId}/password', + [ + 'as' => 'users.password', + 'uses' => 'Users\UsersController@sendPasswordReset', + ] + ); + + Route::get( '{userId}/print', [ 'as' => 'users.print', 'uses' => 'Users\UsersController@printInventory' ]