Skip to content
Snippets Groups Projects
Commit 10a68619 authored by Guilhem CARRON's avatar Guilhem CARRON
Browse files

edit local conf for onDelete

parent 56459d1c
No related branches found
No related tags found
1 merge request!19Feat/us858 save expiration date
Pipeline #42584 failed
...@@ -10,8 +10,11 @@ function isLocal() { ...@@ -10,8 +10,11 @@ function isLocal() {
* Verify if it's an alpha URL * Verify if it's an alpha URL
* @returns {boolean} * @returns {boolean}
*/ */
function isAlpha() { function isDev() {
return process.env.COZY_URL.includes('alpha') return (
process.env.COZY_URL.includes('alpha') ||
process.env.COZY_URL.includes('cozy.tools')
)
} }
module.exports = { isLocal, isAlpha } module.exports = { isLocal, isDev }
...@@ -12,8 +12,7 @@ const moment = require('moment') ...@@ -12,8 +12,7 @@ const moment = require('moment')
require('moment-timezone') require('moment-timezone')
moment.locale('fr') // set the language moment.locale('fr') // set the language
moment.tz.setDefault('Europe/Paris') // set the timezone moment.tz.setDefault('Europe/Paris') // set the timezone
const { isLocal, isAlpha } = require('./helpers/env') const { isLocal, isDev } = require('./helpers/env')
// const ACCOUNT_ID = isLocal() ? 'default_account_id' : 'enedis-sge-grandlyon'
async function onDeleteAccount() { async function onDeleteAccount() {
log('info', 'Deleting account ...') log('info', 'Deleting account ...')
...@@ -36,13 +35,14 @@ async function onDeleteAccount() { ...@@ -36,13 +35,14 @@ async function onDeleteAccount() {
}) })
} }
const secrets = getAccountSecret() const secrets = getAccountSecret()
log('warn', `Account DATAA InOndelete ${JSON.stringify(accountData)}`)
const userConsent = await getBoConsent( const userConsent = await getBoConsent(
secrets.boBaseUrl, secrets.boBaseUrl,
secrets.boToken, secrets.boToken,
accountData.data.consentId accountData.data.consentId
) )
log('info', `isAlpha: ${isAlpha()}`) log('info', `isAlpha: ${isDev()}`)
log('info', `userConsent: ${JSON.stringify(userConsent)}`) log('info', `userConsent: ${JSON.stringify(userConsent)}`)
if (userConsent.ID && userConsent.pointID) { if (userConsent.ID && userConsent.pointID) {
log('log', `Consent ${userConsent.ID} found for user`) log('log', `Consent ${userConsent.ID} found for user`)
...@@ -53,7 +53,7 @@ async function onDeleteAccount() { ...@@ -53,7 +53,7 @@ async function onDeleteAccount() {
userConsent.ID userConsent.ID
) )
// Verify if it's dev env to prevent delete of real data // Verify if it's dev env to prevent delete of real data
if (!isAlpha()) { if (!isDev()) {
await terminateContract( await terminateContract(
secrets.wso2BaseUrl, secrets.wso2BaseUrl,
secrets.apiToken, secrets.apiToken,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment