From 10a6861972049f71bfa22a9cad115608ceb2fd90 Mon Sep 17 00:00:00 2001 From: gcarron <gcarron@grandlyon.com> Date: Mon, 26 Sep 2022 16:56:47 +0200 Subject: [PATCH] edit local conf for onDelete --- src/helpers/env.js | 9 ++++++--- src/onDeleteAccount.js | 8 ++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/helpers/env.js b/src/helpers/env.js index 9e801c4..3774726 100644 --- a/src/helpers/env.js +++ b/src/helpers/env.js @@ -10,8 +10,11 @@ function isLocal() { * Verify if it's an alpha URL * @returns {boolean} */ -function isAlpha() { - return process.env.COZY_URL.includes('alpha') +function isDev() { + return ( + process.env.COZY_URL.includes('alpha') || + process.env.COZY_URL.includes('cozy.tools') + ) } -module.exports = { isLocal, isAlpha } +module.exports = { isLocal, isDev } diff --git a/src/onDeleteAccount.js b/src/onDeleteAccount.js index b0233ee..c625205 100644 --- a/src/onDeleteAccount.js +++ b/src/onDeleteAccount.js @@ -12,8 +12,7 @@ const moment = require('moment') require('moment-timezone') moment.locale('fr') // set the language moment.tz.setDefault('Europe/Paris') // set the timezone -const { isLocal, isAlpha } = require('./helpers/env') -// const ACCOUNT_ID = isLocal() ? 'default_account_id' : 'enedis-sge-grandlyon' +const { isLocal, isDev } = require('./helpers/env') async function onDeleteAccount() { log('info', 'Deleting account ...') @@ -36,13 +35,14 @@ async function onDeleteAccount() { }) } const secrets = getAccountSecret() + log('warn', `Account DATAA InOndelete ${JSON.stringify(accountData)}`) const userConsent = await getBoConsent( secrets.boBaseUrl, secrets.boToken, accountData.data.consentId ) - log('info', `isAlpha: ${isAlpha()}`) + log('info', `isAlpha: ${isDev()}`) log('info', `userConsent: ${JSON.stringify(userConsent)}`) if (userConsent.ID && userConsent.pointID) { log('log', `Consent ${userConsent.ID} found for user`) @@ -53,7 +53,7 @@ async function onDeleteAccount() { userConsent.ID ) // Verify if it's dev env to prevent delete of real data - if (!isAlpha()) { + if (!isDev()) { await terminateContract( secrets.wso2BaseUrl, secrets.apiToken, -- GitLab