fix: prevent settings save from deleting API keys
When saving settings, empty sensitive fields (pagespeedApiKey, globalpingApiKey, systemEmailPassword) were sent as "" to the server, which treated them as $unset operations — deleting the stored keys. Now the form omits these fields from the payload when they're already set and haven't been explicitly reset by the user.
This commit is contained in:
1 parent
1966134647
commit
7f9d2f275e
1 file changed
+12
@@ -112,6 +112,18 @@ const Settings = () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Don't send empty sensitive fields when the key is already set and
|
||||||
|
// hasn't been explicitly reset — otherwise the backend $unsets them
|
||||||
|
if (isApiKeySet && !apiKeyHasBeenReset && !toSubmit.pagespeedApiKey) {
|
||||||
|
delete toSubmit.pagespeedApiKey;
|
||||||
|
}
|
||||||
|
if (isGlobalpingKeySet && !globalpingKeyHasBeenReset && !toSubmit.globalpingApiKey) {
|
||||||
|
delete toSubmit.globalpingApiKey;
|
||||||
|
}
|
||||||
|
if (isEmailPasswordSet && !emailPasswordHasBeenReset && !toSubmit.systemEmailPassword) {
|
||||||
|
delete toSubmit.systemEmailPassword;
|
||||||
|
}
|
||||||
|
|
||||||
saveSettings(toSubmit);
|
saveSettings(toSubmit);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user