From 24dfa41be97a8740c646ee5efbaae96b46b04917 Mon Sep 17 00:00:00 2001 From: Iago Espinoza Date: Wed, 16 Oct 2024 11:03:55 -0300 Subject: [PATCH] fix: error when no email found in jwt due to email rectification feature --- CHANGELOG.md | 2 ++ node/dataSources/identity.ts | 1 + node/directives/withCurrentProfile.ts | 5 +++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c24713f4a..c6e19afb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- Validation for customerID due to email rectification ## [2.172.0] - 2024-10-10 diff --git a/node/dataSources/identity.ts b/node/dataSources/identity.ts index b9cd4c5ab..0f42e1f8c 100644 --- a/node/dataSources/identity.ts +++ b/node/dataSources/identity.ts @@ -10,6 +10,7 @@ export interface DefaultUser { export interface User extends DefaultUser { id: string user: string + customerId: string account: string audience: string } diff --git a/node/directives/withCurrentProfile.ts b/node/directives/withCurrentProfile.ts index b9ccc522b..57b801c43 100644 --- a/node/directives/withCurrentProfile.ts +++ b/node/directives/withCurrentProfile.ts @@ -261,9 +261,10 @@ async function checkUserAccount( !( tokenUser.account === account && (isUserCallCenterOperator || - tokenUser.user.toLowerCase() === currentProfile?.email.toLowerCase()) + tokenUser.user.toLowerCase() === currentProfile?.email.toLowerCase() || + tokenUser.customerId === currentProfile?.userId) ) ) { - throw new AuthenticationError('') + throw new AuthenticationError('Information conflict in tokenUser') } }