diff --git a/packages/nocodb/src/helpers/initDataSourceEncryption.ts b/packages/nocodb/src/helpers/initDataSourceEncryption.ts index 134426162a..f982dea916 100644 --- a/packages/nocodb/src/helpers/initDataSourceEncryption.ts +++ b/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); diff --git a/packages/nocodb/src/utils/encryptDecrypt.ts b/packages/nocodb/src/utils/encryptDecrypt.ts index d2b62df081..052d8f45b3 100644 --- a/packages/nocodb/src/utils/encryptDecrypt.ts +++ b/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 = ({