From bd173886b7a1ca73a65ec7c68ff277df4f6a2480 Mon Sep 17 00:00:00 2001 From: gcarron <gcarron@grandlyon.com> Date: Mon, 3 Oct 2022 16:57:12 +0200 Subject: [PATCH] feat: handle Consent Expired error --- src/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index fe9eaa8..59144ba 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 } -- GitLab