From 1850b6953e0cdb5611dcc49fbd48c46f5a461ec6 Mon Sep 17 00:00:00 2001 From: Bozhidar Slaveykov Date: Mon, 1 Apr 2024 19:57:14 +0300 Subject: [PATCH] update --- web/app/Actions/ApacheWebsiteCreate.php | 17 ++++++++++++++++- .../Listeners/ModelWebsiteCreatingListener.php | 14 +++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/web/app/Actions/ApacheWebsiteCreate.php b/web/app/Actions/ApacheWebsiteCreate.php index 04cbc45..22477cc 100644 --- a/web/app/Actions/ApacheWebsiteCreate.php +++ b/web/app/Actions/ApacheWebsiteCreate.php @@ -10,6 +10,7 @@ class ApacheWebsiteCreate public $domain; public $user; public $email; + public $password; public function setDomain($domain) { @@ -25,6 +26,12 @@ class ApacheWebsiteCreate { $this->email = $email; } + + public function setPassword($password) + { + $this->password = $password; + } + public function handle() { @@ -36,7 +43,7 @@ class ApacheWebsiteCreate $createLinuxWebUser = new CreateLinuxWebUser(); $createLinuxWebUser->setUsername($this->user); $createLinuxWebUser->setEmail($this->email); - $createLinuxWebUser->setPassword('password123'); + $createLinuxWebUser->setPassword($this->password); $createLinuxWebUserOutput = $createLinuxWebUser->handle(); $linuxUser = $getLinuxUser->handle(); } @@ -63,5 +70,13 @@ class ApacheWebsiteCreate $fileManagerApi->filePutContents($settings['domainRoot'].'/index.php', "PHP Time: Domain: " . $settings['domain']); + return [ + 'domain' => $this->domain, + 'user' => $this->user, + 'email' => $this->email, + 'linuxUser' => $linuxUser, + 'apache2Sample' => $apache2Sample + ]; + } } diff --git a/web/app/Listeners/ModelWebsiteCreatingListener.php b/web/app/Listeners/ModelWebsiteCreatingListener.php index 34d8122..8b5469f 100644 --- a/web/app/Listeners/ModelWebsiteCreatingListener.php +++ b/web/app/Listeners/ModelWebsiteCreatingListener.php @@ -2,6 +2,7 @@ namespace App\Listeners; +use App\Actions\ApacheWebsiteCreate; use App\Events\ModelWebsiteCreating; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Queue\InteractsWithQueue; @@ -21,8 +22,19 @@ class ModelWebsiteCreatingListener */ public function handle(ModelWebsiteCreating $event): void { + $model = $event->model; - dd($event); + $username = md5($model->domain); + $email = $username . '@phyrepanel.test'; + $password = uniqid(); + + $newApacheWebsite = new ApacheWebsiteCreate(); + $newApacheWebsite->setDomain($model->domain); + $newApacheWebsite->setUser($username); + $newApacheWebsite->setEmail($email); + $newApacheWebsite->setPassword($password); + + $create = $newApacheWebsite->handle(); } }