diff --git a/app/Services/Servers/ServerAuthService.php b/app/Services/Servers/ServerAuthService.php index e53f2defad6..7c2caac9070 100644 --- a/app/Services/Servers/ServerAuthService.php +++ b/app/Services/Servers/ServerAuthService.php @@ -16,12 +16,15 @@ public function updatePassword(Server $server, string $password) { try { $OsInfo = $this->guestAgentRepository->setServer($server)->guestAgentOs(); - if (str_contains($OsInfo["result"]["name"], "Windows")) { - $username = "Administrator"; - } else { - $username = "root"; + if (is_array($OsInfo) && isset($OsInfo["result"]["name"])) { + if (str_contains($OsInfo["result"]["name"], "Windows")) { + $username = "Administrator"; + } else { + $username = "root"; + } + + $this->guestAgentRepository->setServer($server)->updateGuestAgentPassword($username, $password); } - $this->guestAgentRepository->setServer($server)->updateGuestAgentPassword($username, $password); $this->configRepository->setServer($server)->update(['cipassword' => $password]); } catch (\Exception $e) { $this->configRepository->setServer($server)->update(['cipassword' => $password]);