editing a secret provider no longer wipes its stored token
This commit is contained in:
1 file changed
+11
-11
+11
-11
@@ -379,18 +379,18 @@ export async function updateSecretProvider(
|
|||||||
if (data.config !== undefined) {
|
if (data.config !== undefined) {
|
||||||
// The edit form pre-fills non-secret fields but leaves the token blank to mean
|
// The edit form pre-fills non-secret fields but leaves the token blank to mean
|
||||||
// "keep the stored secret". Merge the incoming config OVER the existing one so a
|
// "keep the stored secret". Merge the incoming config OVER the existing one so a
|
||||||
// blank/absent secret keeps its stored value instead of being wiped. Only applies
|
// blank/absent secret keeps its stored value instead of being wiped. The edit
|
||||||
// when the provider type is unchanged (a type change is a full re-config).
|
// form always sends `type` (its dropdown is read-only), so gate on the type not
|
||||||
|
// CHANGING rather than on it being absent - a genuine type change is a full
|
||||||
|
// re-config and skips the merge. (#1432)
|
||||||
let merged: Record<string, unknown> = { ...(data.config as Record<string, unknown>) };
|
let merged: Record<string, unknown> = { ...(data.config as Record<string, unknown>) };
|
||||||
const typeUnchanged = data.type === undefined;
|
const existing = await getSecretProviderById(id);
|
||||||
if (typeUnchanged) {
|
const typeUnchanged = data.type === undefined || (existing !== undefined && data.type === existing.type);
|
||||||
const existing = await getSecretProviderById(id);
|
if (typeUnchanged && existing) {
|
||||||
if (existing) {
|
merged = mergeProviderConfigForWrite(
|
||||||
merged = mergeProviderConfigForWrite(
|
data.config as Record<string, unknown>,
|
||||||
data.config as Record<string, unknown>,
|
existing.config as Record<string, unknown>
|
||||||
existing.config as Record<string, unknown>
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const encrypted = encrypt(JSON.stringify(merged));
|
const encrypted = encrypt(JSON.stringify(merged));
|
||||||
if (encrypted) updateData.config = encrypted;
|
if (encrypted) updateData.config = encrypted;
|
||||||
|
|||||||
Reference in new issue
Block a user