diff --git a/index.js b/index.js index beadda3a8e4fdc651f94e263db1f3c5b1064f3f5..6ed7fba8b3d27aa7c740bfdb47d75c78acb17737 100644 --- a/index.js +++ b/index.js @@ -128,6 +128,7 @@ async function verifyUserIdentity( loginUtilisateur ) { const inseeCode = await getInseeCode(fields.postalCode) + if (!inseeCode) throw errors.USER_ACTION_NEEDED const pdl = await findUserPdl( `${baseUrl}/enedis_SDE_recherche-point/1.0`, @@ -223649,8 +223650,8 @@ const API_URL = 'https://apicarto.ign.fr/api/codes-postaux/communes' */ async function getInseeCode(postalCode, city) { try { - const response = await axios.get(`${API_URL}/${postalCode}`) log('info', `Query getInseeCode for postalCode ${postalCode} / ${city}`) + const response = await axios.get(`${API_URL}/${postalCode}`) if (response.data.length === 1) { return response.data[0].codeCommune @@ -223663,6 +223664,10 @@ async function getInseeCode(postalCode, city) { return filteredResponse[0].codeCommune } } catch (error) { + log( + 'error', + `Query getInseeCode failed for postalCode ${postalCode} / ${city}` + ) return null } }