fixes
This commit is contained in:
@@ -7,7 +7,6 @@ use Livewire\Component;
|
||||
|
||||
class Change extends Component
|
||||
{
|
||||
public string $private_key_uuid;
|
||||
public PrivateKey $private_key;
|
||||
|
||||
protected $rules = [
|
||||
@@ -20,15 +19,15 @@ class Change extends Component
|
||||
'private_key.description' => 'description',
|
||||
'private_key.private_key' => 'private key'
|
||||
];
|
||||
public function mount()
|
||||
{
|
||||
$this->private_key = PrivateKey::where('uuid', $this->private_key_uuid)->first();
|
||||
}
|
||||
public function delete()
|
||||
{
|
||||
PrivateKey::where('uuid', $this->private_key_uuid)->delete();
|
||||
session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
|
||||
redirect()->route('dashboard');
|
||||
try {
|
||||
PrivateKey::where('uuid', $this->private_key_uuid)->delete();
|
||||
session('currentTeam')->privateKeys = PrivateKey::where('team_id', session('currentTeam')->id)->get();
|
||||
redirect()->route('dashboard');
|
||||
} catch (\Exception $e) {
|
||||
return general_error_handler(err: $e, that: $this);
|
||||
}
|
||||
}
|
||||
public function changePrivateKey()
|
||||
{
|
||||
|
||||
@@ -5,12 +5,27 @@ namespace App\Http\Livewire\Server;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Component;
|
||||
use Masmerise\Toaster\Toaster;
|
||||
|
||||
class PrivateKey extends Component
|
||||
{
|
||||
public Server $server;
|
||||
public $privateKeys;
|
||||
public $parameters;
|
||||
|
||||
public function checkConnection()
|
||||
{
|
||||
try {
|
||||
$uptime = instant_remote_process(['uptime'], $this->server, false);
|
||||
if ($uptime) {
|
||||
Toaster::success('Server is reachable with this private key.');
|
||||
} else {
|
||||
Toaster::error('Server is NOT reachable with this private key.');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return general_error_handler(err: $e, that: $this);
|
||||
}
|
||||
}
|
||||
public function setPrivateKey($private_key_id)
|
||||
{
|
||||
$this->server->update([
|
||||
@@ -18,8 +33,9 @@ class PrivateKey extends Component
|
||||
]);
|
||||
|
||||
// Delete the old ssh mux file to force a new one to be created
|
||||
Storage::disk('ssh-mux')->delete("{$this->server->first()->ip}_{$this->server->first()->port}_{$this->server->first()->user}");
|
||||
Storage::disk('ssh-mux')->delete($this->server->muxFilename());
|
||||
$this->server->refresh();
|
||||
$this->checkConnection();
|
||||
}
|
||||
public function mount()
|
||||
{
|
||||
|
||||
@@ -11,9 +11,6 @@ class PrivateKey extends BaseModel
|
||||
'private_key',
|
||||
'team_id',
|
||||
];
|
||||
protected $hidden = [
|
||||
'private_key',
|
||||
];
|
||||
static public function ownedByCurrentTeam(array $select = ['*'])
|
||||
{
|
||||
$selectArray = collect($select)->concat(['id']);
|
||||
|
||||
@@ -74,6 +74,10 @@ class Server extends BaseModel
|
||||
{
|
||||
return $this->hasOne(ServerSetting::class);
|
||||
}
|
||||
public function muxFilename()
|
||||
{
|
||||
return "{$this->ip}_{$this->port}_{$this->user}";
|
||||
}
|
||||
static public function ownedByCurrentTeam(array $select = ['*'])
|
||||
{
|
||||
$selectArray = collect($select)->concat(['id']);
|
||||
|
||||
Reference in New Issue
Block a user