fix(client-service): hide service/vm ids, mask vm password, encrypt module_vmware.password

- detail response drops id and vm.id/vmware_id, password returns *****
- GET client-service/{uuid}/vm-password returns the decrypted password to the owner
- renew accepts service uuid
- EncryptedOrLegacy cast for module_vmware.password
- vps specs: addon ram is stored in MB, convert to GB

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
baodev0
2026-10-20 15:52:56 +07:00
co-authored by Claude Sonnet 5.5
parent 66c7c0a6c3
commit 3c7710f1de
7 changed files with 57 additions and 12 deletions
@@ -10,6 +10,8 @@ use Illuminate\Support\Facades\Crypt;
class ServiceClientDetailResource extends JsonResource
{
public const MASKED_PASSWORD = '*****';
/** Plesk panel login (persisted, reusable) — separate from the one-time FTP password, which is never stored. */
private function resolvePleskCredentials($hosting): ?array
{
@@ -60,7 +62,7 @@ class ServiceClientDetailResource extends JsonResource
if ($addons->isNotEmpty()) {
return [
'cpu' => (int) $addons->where('addon_type', 'cpu')->sum('addon_value'),
'ram' => (int) $addons->where('addon_type', 'ram')->sum('addon_value'),
'ram' => round($addons->where('addon_type', 'ram')->sum('addon_value') / 1024, 2),
'disk' => (int) $addons->where('addon_type', 'disk')->sum('addon_value'),
'bandwidth' => (int) $addons->where('addon_type', 'bandwidth')->sum('addon_value'),
];
@@ -89,7 +91,6 @@ class ServiceClientDetailResource extends JsonResource
$dnsCancelled = $dnsZone !== null && (int) $dnsZone->is_created === DnsDomain::STATUS_CANCELLED;
return [
'id' => $this->id,
'uuid' => $this->uuid,
'type' => $this->type,
'server_name' => $this->server_name,
@@ -115,12 +116,10 @@ class ServiceClientDetailResource extends JsonResource
'renewal_options' => \App\Support\RenewalPricing::options($product),
] : null,
'vm' => $vm ? [
'id' => $vm->id,
'vmware_id' => $vm->vmware_id,
'ip_address' => $vm->ipAddress?->ip ?? $vm->ip,
'hostname' => $vm->hostname,
'username' => $vm->user,
'password' => $vm->plain_password ?? null,
'password' => $vm->plain_password ? self::MASKED_PASSWORD : null,
'port' => $vm->port,
'status' => $vm->status,
'ip' => $vm->ip ?? null,