mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 22:46:16 +00:00
refactoring (#116)
- refactoring architecture - fix incomplete ssh logs - code editor for scripts in the app - remove Jobs and SSHCommands
This commit is contained in:
@ -2,8 +2,10 @@
|
||||
|
||||
namespace App\Actions\SSL;
|
||||
|
||||
use App\Enums\SslStatus;
|
||||
use App\Enums\SslType;
|
||||
use App\Models\Site;
|
||||
use App\Models\Ssl;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
@ -17,13 +19,24 @@ public function create(Site $site, array $input): void
|
||||
{
|
||||
$this->validate($input);
|
||||
|
||||
if ($input['type'] == SslType::LETSENCRYPT) {
|
||||
$site->createFreeSsl();
|
||||
}
|
||||
$ssl = new Ssl([
|
||||
'site_id' => $site->id,
|
||||
'type' => $input['type'],
|
||||
'certificate' => $input['certificate'] ?? null,
|
||||
'pk' => $input['private'] ?? null,
|
||||
'expires_at' => $input['type'] === SslType::LETSENCRYPT ? now()->addMonths(3) : null,
|
||||
'status' => SslStatus::CREATING,
|
||||
]);
|
||||
$ssl->save();
|
||||
|
||||
if ($input['type'] == SslType::CUSTOM) {
|
||||
$site->createCustomSsl($input['certificate'], $input['private']);
|
||||
}
|
||||
dispatch(function () use ($site, $ssl) {
|
||||
$site->server->webserver()->handler()->setupSSL($ssl);
|
||||
$ssl->status = SslStatus::CREATED;
|
||||
$ssl->save();
|
||||
$site->type()->edit();
|
||||
})->catch(function () use ($ssl) {
|
||||
$ssl->delete();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
14
app/Actions/SSL/DeleteSSL.php
Normal file
14
app/Actions/SSL/DeleteSSL.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\SSL;
|
||||
|
||||
use App\Models\Ssl;
|
||||
|
||||
class DeleteSSL
|
||||
{
|
||||
public function delete(Ssl $ssl): void
|
||||
{
|
||||
$ssl->site->server->webserver()->handler()->removeSSL($ssl);
|
||||
$ssl->delete();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user