Conversation
…ected `EcCheckout.login()` set `customerEmail` (and so `isUserIdentified`) as soon as the passport cookie had an `auth.id`, before `fetchCustomer` confirmed the session. `checkLogin()` does not validate the token, so an expired token led to 401 on `/customers/:id`, `ecomPassport.logout()`, and a checkout stuck on the AccountForm with e-mail only, as if the customer were new: returning customers re-registered and orders created duplicated customers. Now the buyer is identified only once the account is loaded, via the `customer.main_email` watcher, and `Checkout.login()` resets the account state when the fetch fails with the session dropped, so the LoginBlock stays and picks the `login` event when the token is renewed. 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 #1314 + vbeta-app com ecomplus/cloud-commerce#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 abre
/app/#/checkoutcom o cookieecomPassportClientguardando um token vencido.checkLogin()só checaauth.id, oLoginBlockemiteloginna montagem, eEcCheckout.login()já marcava o comprador como identificado (customerEmail→isUserIdentified) antes dofetchCustomer. OGET /customers/:iddá 401, oaccount.jsfazlogout(), e nada volta o estado: o checkout fica noAccountFormsó com o e-mail, como se fosse cliente novo. Relato recorrente da Barradoce/Tia Sônia desde 05/2026, com clientes duplicados nos pedidos.Os fixes anteriores (#1290 e #1298) atacaram a corrida do token, mas nenhum tratava o resultado do 401.
Mudança
EcCheckout.login()só emitelogin; a identificação passa a acontecer pelo watcher decustomer.main_emailquando o cadastro é carregado.Checkout.login()chamaresetAccountquando o fetch falha e o passport já deslogou, então oLoginBlockcontinua na tela e captura o eventologinquando o token é renovado pelo storefront.Teste
Reproduzido em produção com Playwright (token vencido + cookie antigo + sem usuário Firebase → 2x 401 e AccountForm). Com esta build servida num preview da Barradoce, o mesmo cenário termina na tela de e-mail. Complementa
ecomplus/cloud-commerce(vbeta-app deixa de entregar cookie vencido ao app.js).🤖 Generated with Claude Code