From 575cb072b8c7e4007f41b3a83110e88d6a9abaad Mon Sep 17 00:00:00 2001 From: Vitor Date: Wed, 16 Sep 2026 16:23:11 -0300 Subject: [PATCH 1/2] fix(checkout): return to identification when the session token is rejected `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 --- @ecomplus/storefront-app/src/components/js/EcCheckout.js | 5 ++++- @ecomplus/storefront-app/src/views/js/Checkout.js | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/@ecomplus/storefront-app/src/components/js/EcCheckout.js b/@ecomplus/storefront-app/src/components/js/EcCheckout.js index c1b73904f..5834ea09e 100644 --- a/@ecomplus/storefront-app/src/components/js/EcCheckout.js +++ b/@ecomplus/storefront-app/src/components/js/EcCheckout.js @@ -307,7 +307,10 @@ export default { login (ecomPassport) { if (ecomPassport.checkLogin()) { - this.customerEmail = ecomPassport.getCustomer().main_email + // Buyer is identified only after the account is fetched: the + // `customer.main_email` watcher sets `customerEmail` then. Setting it + // here would keep the buyer identified with e-mail only when the fetch + // fails (expired token, 401) and show the account form as new customer. this.$emit('login', ecomPassport) } }, diff --git a/@ecomplus/storefront-app/src/views/js/Checkout.js b/@ecomplus/storefront-app/src/views/js/Checkout.js index d45481bdc..b43f5ec63 100644 --- a/@ecomplus/storefront-app/src/views/js/Checkout.js +++ b/@ecomplus/storefront-app/src/views/js/Checkout.js @@ -118,7 +118,8 @@ export default { 'selectPaymentGateway', 'setCustomer', 'selectAddress', - 'addOrder' + 'addOrder', + 'resetAccount' ]), ...mapActions([ @@ -132,6 +133,12 @@ export default { this.ecomPassport = ecomPassport this.triggerLoading(true) this.fetchCustomer({ ecomPassport }) + .catch(() => { + if (!ecomPassport.checkLogin()) { + // session dropped (401 with stale token), back to identification + this.resetAccount() + } + }) .finally(() => this.triggerLoading(false)) }, From 065532543f2537749f519b0ca20c8b2b6cda1322 Mon Sep 17 00:00:00 2001 From: Leonardo Matos Date: Mon, 21 Sep 2026 15:34:54 -0300 Subject: [PATCH 2/2] chore(checkout): trim comments on login fetch handling Co-Authored-By: Claude Opus 5 --- @ecomplus/storefront-app/src/components/js/EcCheckout.js | 6 ++---- @ecomplus/storefront-app/src/views/js/Checkout.js | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/@ecomplus/storefront-app/src/components/js/EcCheckout.js b/@ecomplus/storefront-app/src/components/js/EcCheckout.js index 5834ea09e..3bfed2a0c 100644 --- a/@ecomplus/storefront-app/src/components/js/EcCheckout.js +++ b/@ecomplus/storefront-app/src/components/js/EcCheckout.js @@ -307,10 +307,8 @@ export default { login (ecomPassport) { if (ecomPassport.checkLogin()) { - // Buyer is identified only after the account is fetched: the - // `customer.main_email` watcher sets `customerEmail` then. Setting it - // here would keep the buyer identified with e-mail only when the fetch - // fails (expired token, 401) and show the account form as new customer. + // don't set `customerEmail` here, the fetch may fail (401) and leave + // the buyer identified with e-mail only, as a new customer this.$emit('login', ecomPassport) } }, diff --git a/@ecomplus/storefront-app/src/views/js/Checkout.js b/@ecomplus/storefront-app/src/views/js/Checkout.js index b43f5ec63..9641b0a88 100644 --- a/@ecomplus/storefront-app/src/views/js/Checkout.js +++ b/@ecomplus/storefront-app/src/views/js/Checkout.js @@ -135,7 +135,7 @@ export default { this.fetchCustomer({ ecomPassport }) .catch(() => { if (!ecomPassport.checkLogin()) { - // session dropped (401 with stale token), back to identification + // `fetchCustomer` logs out on 401 (stale token) this.resetAccount() } })