reverted some line in the Handle-fetchsite to powershell 5 commands
This commit is contained in:
@@ -266,10 +266,12 @@ function Handle-FetchSites {
|
|||||||
param($Context)
|
param($Context)
|
||||||
|
|
||||||
# 1) Read incoming JSON (using block auto-disposes the reader)
|
# 1) Read incoming JSON (using block auto-disposes the reader)
|
||||||
using ($reader = [IO.StreamReader]::new($Context.Request.InputStream)) {
|
|
||||||
|
|
||||||
|
<# powershell v7
|
||||||
|
using ($reader = [IO.StreamReader]::new($Context.Request.InputStream)) {
|
||||||
$raw = $reader.ReadToEnd()
|
$raw = $reader.ReadToEnd()
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$pw = (ConvertFrom-Json $raw).password
|
$pw = (ConvertFrom-Json $raw).password
|
||||||
if (-not $pw) { throw "Missing `password` field" }
|
if (-not $pw) { throw "Missing `password` field" }
|
||||||
@@ -278,6 +280,22 @@ function Handle-FetchSites {
|
|||||||
returnRespondEmpty $Context 400
|
returnRespondEmpty $Context 400
|
||||||
return
|
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
|
# 2) Fetch your Datto API creds from the webhook
|
||||||
Write-LogHybrid "Calling webhook for Datto credentials…" "Info" "FetchSites"
|
Write-LogHybrid "Calling webhook for Datto credentials…" "Info" "FetchSites"
|
||||||
|
|||||||
Reference in New Issue
Block a user