diff --git a/src/index.js b/src/index.js index fe9eaa82793e121eb388a8fcc35a0501fd53b57d..59144ba28d1194a8bd4f4c042e9c3f6dee542865 100644 --- a/src/index.js +++ b/src/index.js @@ -209,9 +209,9 @@ async function start(fields, cozyParameters) { contractId, pointId, boBaseUrl, - boToken + boToken, + consentEndDate < today ) - throw errors.USER_ACTION_NEEDED_OAUTH_OUTDATED } } log('info', 'Successfully logged in') @@ -229,6 +229,7 @@ async function start(fields, cozyParameters) { * @param {number} pointId * @param {string} boBaseUrl * @param {string} boToken + * @param {boolean} isConsentExpiration */ async function deleteConsent( userConsent, @@ -238,7 +239,8 @@ async function deleteConsent( contractId, pointId, boBaseUrl, - boToken + boToken, + isConsentExpiration ) { log('error', `Invalid or not found consent for user`) if (userConsent.serviceID) { @@ -255,6 +257,9 @@ async function deleteConsent( log('error', `No service id retrieved from BO`) throw errors.VENDOR_DOWN } + if (isConsentExpiration) { + throw errors.USER_ACTION_NEEDED_OAUTH_OUTDATED + } throw errors.TERMS_VERSION_MISMATCH }