fix(checkout): skip AccountForm when passport session is invalid#1290
Open
vitorrgg wants to merge 1 commit into
Open
fix(checkout): skip AccountForm when passport session is invalid#1290vitorrgg wants to merge 1 commit into
vitorrgg wants to merge 1 commit into
Conversation
isUserIdentified now requires ecomPassport.checkLogin() in addition to a Vuex email, preventing the component from jumping directly to AccountForm when customer.main_email is stale from a previous SPA interaction. Also fixes the customer.main_email watcher to reset isUserIdentified and customerEmail when the email is cleared, so the state cannot get stuck in a truthy value during the same session. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problema
Ao clicar em "Finalizar Compra", usuários com interações anteriores no checkout na mesma sessão SPA eram enviados diretamente para "Complete seu cadastro" (AccountForm) em vez de ver o campo de email (LoginBlock). Recarregar a página resolvia.
Causa raiz
EcCheckout inicializa isUserIdentified = Boolean(this.customer.main_email) — sincronamente, a partir do Vuex. O Vuex retém o main_email em memória durante toda a sessão SPA sempre que o usuário digita no campo de email do checkout. Na próxima visita ao checkout (mesma aba, sem reload), o componente já nasce com isUserIdentified = true, mas sem perfil completo (hasBuyerInfo = false), caindo direto no AccountForm sem passar pelo LoginBlock.
Evidência
Capturado ao vivo com o bug ativo: Vuex tinha main_email preenchido, mas _id, name e phones vazios. ecomPassport.checkLogin() retornava false e getCustomer() retornava {} — nenhuma sessão válida no passport-client. O estado do Vuex e do passport-client estavam completamente desincronizados.
Adicionalmente: ao resetar o Vuex via console, a tela não mudou — isUserIdentified é estado local do componente e o watcher de customer.main_email só age quando o email é truthy, nunca revertendo para false.
Correção
Vincular isUserIdentified à existência de sessão válida no passport-client na inicialização, e corrigir o watcher para também reagir quando o email é removido.