diff --git a/app/Jobs/Auth/CreateUser.php b/app/Jobs/Auth/CreateUser.php index ce341f03b..92ca09473 100644 --- a/app/Jobs/Auth/CreateUser.php +++ b/app/Jobs/Auth/CreateUser.php @@ -19,7 +19,7 @@ class CreateUser extends Job implements HasOwner, HasSource, ShouldCreate event(new UserCreating($this->request)); \DB::transaction(function () { - if (! app()->runningInConsole() && ! request()->isInstall()) { + if (empty($this->request->get('password', false))) { $this->request->merge(['password' => Str::random(40)]); } @@ -71,7 +71,7 @@ class CreateUser extends Job implements HasOwner, HasSource, ShouldCreate ]); } - if ((! app()->runningInConsole() && ! request()->isInstall()) || app()->runningUnitTests()) { + if ($this->shouldSendInvitation()) { $this->dispatch(new CreateInvitation($this->model)); } }); @@ -80,4 +80,17 @@ class CreateUser extends Job implements HasOwner, HasSource, ShouldCreate return $this->model; } + + protected function shouldSendInvitation() + { + if (app()->runningInConsole()) { + return false; + } + + if (request()->isInstall()) { + return false; + } + + return true; + } }