From 7f9d2f275e77d464cca5a86a368ebca740edf913 Mon Sep 17 00:00:00 2001 From: gorkem-bwl Date: Thu, 19 Feb 2026 11:04:21 -0500 Subject: [PATCH] fix: prevent settings save from deleting API keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- client/src/Pages/Settings/index.jsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/client/src/Pages/Settings/index.jsx b/client/src/Pages/Settings/index.jsx index 01e46248a..f8f1d109b 100644 --- a/client/src/Pages/Settings/index.jsx +++ b/client/src/Pages/Settings/index.jsx @@ -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); };