Browse Source

fix: stringify only if value is not string

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/9610/head
Pranav C 2 months ago
parent
commit
22ab34a35e
  1. 2
      packages/nocodb/src/helpers/initDataSourceEncryption.ts
  2. 7
      packages/nocodb/src/utils/encryptDecrypt.ts

2
packages/nocodb/src/helpers/initDataSourceEncryption.ts

@ -73,7 +73,7 @@ export default async function initDataSourceEncryption(_ncMeta = Noco.ncMeta) {
// check if valid json, if not warn and skip
try {
JSON.parse(integrations.config);
JSON.parse(integration.config);
} catch (e) {
logger.warn('Invalid JSON in integration config', integration.title);
successStatus.push(false);

7
packages/nocodb/src/utils/encryptDecrypt.ts

@ -19,11 +19,14 @@ export const encryptPropIfRequired = ({
return;
}
const val =
typeof data[prop] === 'string' ? data[prop] : JSON.stringify(data[prop]);
if (!secret) {
return JSON.stringify(data[prop]);
return val;
}
return CryptoJS.AES.encrypt(JSON.stringify(data[prop]), secret).toString();
return CryptoJS.AES.encrypt(val, secret).toString();
};
export const decryptPropIfRequired = ({

Loading…
Cancel
Save