Conversation
Returning customers whose stored token had expired were dropped on the "complete your registration" form as if they were new, and orders created duplicated customers. The legacy app.js trusts any `auth.id` on the `ecomPassportClient` cookie (no expiry check), requests `/customers/:id` with the dead token, gets 401 and logs out without leaving the form. vbeta-app now drops that cookie when the Cloud Commerce session is not authenticated and the cookie was written by it (level 3), keeping legacy e-mail + document identifications untouched. app.js then starts unidentified and receives the `login` event when the token is renewed, either before it loads (#785 wait) or later through `setSession`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Member
Author
Resultado do teste no previewPreview: https://ecom2barradoce--pr134-fix-checkout-recover-tv82ga7c.web.app (storefront-app com ecomplus/storefront#1314 + vbeta-app com #842)
Script: Playwright headless, sem criar pedido. Fica em |
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
Cliente já cadastrado volta à loja depois que o token do passport expirou. O cookie
ecomPassportClientcontinua com o token vencido (6 dias), oapp.jslegado confia em qualquerauth.id(checkLogin()não valida expiração), fazGET /customers/:id, recebe 401, fazlogout()e o checkout fica no formulário "Complete seu cadastro" como cliente novo. Relato recorrente da Barradoce desde 05/2026, ainda reproduzido em 15/09 após o #785 e o beta.228.Reproduzido em produção com Playwright: token vencido no
ecomSession+ cookie antigo + sem usuário Firebase → nenhum POST em/_api/passport/token, 2x 401 e AccountForm. Quando a renovação do #785 não acontece (sem usuário Firebase o app carrega na hora; falha ou cold start > 10s em/_api/passport/token), o resultado é sempre esse.Mudança
No
watch(isAuthenticated)do vbeta-app, quando a sessão não está autenticada e oapp.jsainda não carregou, apaga o cookieecomPassportClientse ele tiverauth.level === 3(só o Cloud Commerce grava esse nível). Identificações legadas por e-mail + documento (nível 0 a 2) não são tocadas. Oapp.jssobe sem identificação, mostra a tela de e-mail, e recebe o eventologinviasetSessionassim que o token é renovado.Complementa
ecomplus/storefront(fix/checkout-recover-from-401), que faz o checkout voltar à identificação quando o fetch do cliente falha.Teste
Preview na Barradoce com este vbeta-app (override local) + build do storefront-app com o fix. Mesmo cenário do Playwright termina na tela de e-mail, sem 401.
🤖 Generated with Claude Code