fix(web): correct secret field extraction in channel config payload builder
The previous `buildSavePayload` loop would skip any secret field coming from `editConfig` that started with an underscore (like `_token`), but relied on the loop having visited an existing secret key (like `token`) first. When adding a new channel configuration where the `token` didn't exist, the loop ignored the input completely, leading to a false positive "This field is required." error in the UI. This fix splits the payload builder into two passes: one to copy regular fields and a separate one iterating specifically over `SECRET_FIELD_MAP` to ensure any new secret field inputs are securely captured and saved. Co-authored-by: TanLuong <28281768+TanLuong@users.noreply.github.com>
This commit is contained in:
parent
5d9bbb7513
commit
b05489bff4
1 changed files with 9 additions and 7 deletions
|
|
@ -95,16 +95,18 @@ function buildSavePayload(
|
||||||
if (key.startsWith("_")) continue
|
if (key.startsWith("_")) continue
|
||||||
if (key === "enabled") continue
|
if (key === "enabled") continue
|
||||||
|
|
||||||
if (key in SECRET_FIELD_MAP) {
|
|
||||||
const editKey = SECRET_FIELD_MAP[key]
|
|
||||||
const incoming = asString(editConfig[editKey])
|
|
||||||
payload[key] = incoming !== "" ? incoming : value
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
payload[key] = value
|
payload[key] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const [key, editKey] of Object.entries(SECRET_FIELD_MAP)) {
|
||||||
|
if (editKey in editConfig) {
|
||||||
|
const incoming = asString(editConfig[editKey])
|
||||||
|
if (incoming !== "") {
|
||||||
|
payload[key] = incoming
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (channel.name === "whatsapp_native") {
|
if (channel.name === "whatsapp_native") {
|
||||||
payload.use_native = true
|
payload.use_native = true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue