reverted some line in the Handle-fetchsite to powershell 5 commands

This commit is contained in:
2025-05-29 01:55:01 -04:00
parent 979f6ba102
commit 2dde224072

View File

@@ -266,10 +266,12 @@ function Handle-FetchSites {
param($Context)
# 1) Read incoming JSON (using block auto-disposes the reader)
<# powershell v7
using ($reader = [IO.StreamReader]::new($Context.Request.InputStream)) {
$raw = $reader.ReadToEnd()
}
try {
$pw = (ConvertFrom-Json $raw).password
if (-not $pw) { throw "Missing `password` field" }
@@ -278,6 +280,22 @@ function Handle-FetchSites {
returnRespondEmpty $Context 400
return
}
#>
$reader = [IO.StreamReader]::new($Context.Request.InputStream)
try {
$raw = $reader.ReadToEnd()
} finally {
$reader.Close()
}
try {
$pw = (ConvertFrom-Json $raw).password
} catch {
Write-LogHybrid "Invalid JSON in /getpw payload: $($_.Exception.Message)" "Error" "FetchSites"
returnRespondEmpty $Context
return
}
# 2) Fetch your Datto API creds from the webhook
Write-LogHybrid "Calling webhook for Datto credentials…" "Info" "FetchSites"