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

Conversation

iago1501
Copy link
Contributor

What problem is this solving?

Now it's possible to navigate at VTEX without email, it's a new feature called email rectification. In this scenario, the validation must be done by the customerId. From now on, every user will have their own customerId and it's supposed to not use email as a primary key anymore

How to test it?

You must follow several steps in order to create your user with the permissions, so, when reviewing this, please, contact to me so I can give you the access

  • Log with your authorized email in account b2bsuite

Before

image

After

image

How does this PR make you feel? 🔗

@iago1501 iago1501 self-assigned this Sep 20, 2024
@iago1501 iago1501 requested a review from a team as a code owner September 20, 2024 18:46
@iago1501 iago1501 requested review from eduardoformiga, lucasfp13 and leo-prange-vtex and removed request for a team September 20, 2024 18:46
Copy link
Contributor

vtex-io-ci-cd bot commented Sep 20, 2024

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)

  • Minor (backwards-compatible functionality)

  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

@vtex-io-docs-bot
Copy link

vtex-io-docs-bot bot commented Sep 20, 2024

Beep boop 🤖

I noticed you didn't make any changes at the docs/ folder

  • There's nothing new to document 🤔
  • I'll do it later 😞

In order to keep track, I'll create an issue if you decide now is not a good time

  • I just updated 🎉🎉

@@ -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?

Copy link
Contributor

@vsseixaso vsseixaso left a comment

Choose a reason for hiding this comment

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

LGTM!

@iago1501 iago1501 merged commit 24dfa41 into master Oct 16, 2024
5 checks passed
@iago1501 iago1501 deleted the feat/customerId-validation branch October 16, 2024 14:03
Copy link
Contributor

vtex-io-ci-cd bot commented Oct 16, 2024

Your PR has been merged! App is being published. 🚀
Version 2.172.0 → 2.172.1

After the publishing process has been completed (check #vtex-io-releases) and doing A/B tests with the new version, you can deploy your release by running:

vtex deploy [email protected]

After that your app will be updated on all accounts.

For more information on the deployment process check the docs. 📖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants