Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error when no email found in jwt due to email rectification feature #673

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.171.2] - 2024-09-04

Expand Down
1 change: 1 addition & 0 deletions node/dataSources/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface DefaultUser {
export interface User extends DefaultUser {
id: string
user: string
customerId: string
account: string
audience: string
}
Expand Down
5 changes: 3 additions & 2 deletions node/directives/withCurrentProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iago1501 caso não tenha customerId (caso geral), e o currentProfile seja nulo, vai dar verdadeiro?

Copy link
Contributor Author

@iago1501 iago1501 Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isso @rafaelnader , é que a lógica desse cara foi feita invertida, também fiquei confuso pra entender.

No teu exemplo, esse condicional de dentro vai dar false, mas tem o bang (!) antes pra inverter e dar verdadeiro, e daí, ele vai disparar o erro porque esse condicional é para disparar o erro.

Basicamente tudo o que ta dentro do parêntese é esperado que retorne true pra ele retornar false e não cair no erro 😵‍💫

Essa foi sua dúvida?

)
) {
throw new AuthenticationError('')
throw new AuthenticationError('Information conflict in tokenUser')
}
}
Loading