From 5fdbe11a3ea39af44bb1415ce2a850ec178fa3ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Pailharey?= <rpailharey@grandlyon.com> Date: Tue, 27 Feb 2024 15:32:38 +0100 Subject: [PATCH] fix: TERMS_VERSION_MISMATCH error --- __tests__/core/verifyUserIdentity.spec.js | 4 ++-- src/core/verifyUserIdentity.js | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/__tests__/core/verifyUserIdentity.spec.js b/__tests__/core/verifyUserIdentity.spec.js index 9563578..c1488b5 100644 --- a/__tests__/core/verifyUserIdentity.spec.js +++ b/__tests__/core/verifyUserIdentity.spec.js @@ -39,7 +39,7 @@ describe('verifyUserIdentity', () => { } }) - it('should throw TERMS_VERSION_MISMATCH when pdl give and received are NOT matching on alternate start 🚫', async () => { + it('should throw USER_ACTION_NEEDED_PERMISSIONS_CHANGED when pdl give and received are NOT matching on alternate start 🚫', async () => { findUserPdl.mockResolvedValueOnce('12345') try { await verifyUserIdentity( @@ -56,7 +56,7 @@ describe('verifyUserIdentity', () => { ) expect(true).toBe(false) } catch (error) { - expect(error.message).toBe(errors.TERMS_VERSION_MISMATCH) + expect(error.message).toBe(errors.USER_ACTION_NEEDED_PERMISSIONS_CHANGED) } }) diff --git a/src/core/verifyUserIdentity.js b/src/core/verifyUserIdentity.js index 08a7d20..d535eab 100644 --- a/src/core/verifyUserIdentity.js +++ b/src/core/verifyUserIdentity.js @@ -67,7 +67,7 @@ async function verifyUserIdentity( userAddress.escalierEtEtageEtAppartement ? removeMultipleSpaces(userAddress.escalierEtEtageEtAppartement) : '' - + // Second try, trim whitespace pdl = await findUserPdl( `${baseUrl}/enedis_SDE_recherche-point/1.0`, apiAuthKey, @@ -134,13 +134,15 @@ async function verifyUserIdentity( log('error', 'PointId does not match') if (isAlternateStart) { - Sentry.captureException('PointId does not match: Alternate start', { + Sentry.captureException('PointId no longer match', { tags: { section: 'verifyUserIdentity' }, + extra: { foundPdl: pdl }, }) - throw new Error(errors.TERMS_VERSION_MISMATCH) + throw new Error(errors.USER_ACTION_NEEDED_PERMISSIONS_CHANGED) } else { Sentry.captureException('PointId does not match', { tags: { section: 'verifyUserIdentity' }, + extra: { foundPdl: pdl }, }) throw new Error(errors.LOGIN_FAILED) } -- GitLab