From b3b9a2807ea136c4e2b8a4894a32bcb89dd5b385 Mon Sep 17 00:00:00 2001 From: mihainutiu-vtex Date: Tue, 5 Sep 2023 10:05:17 +0300 Subject: [PATCH 1/4] fixed unauthenticated user issue --- checkout-ui-custom/checkout6-custom.js | 2 +- node/yarn.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/checkout-ui-custom/checkout6-custom.js b/checkout-ui-custom/checkout6-custom.js index e92fcaa..6f580b6 100644 --- a/checkout-ui-custom/checkout6-custom.js +++ b/checkout-ui-custom/checkout6-custom.js @@ -444,7 +444,7 @@ const MAX_TIME_EXPIRATION = 1000 * 60 * 5 // 5 minutes isWorkspace() ? `?v=${ts}` : '' }`, }).then(function (response) { - if (Object.keys(response).length === 0) { + if (Object.keys(response).length === 0 || response[0] === 'User not authenticated') { window.sessionStorage.removeItem('b2b-checkout-settings') return diff --git a/node/yarn.lock b/node/yarn.lock index 1b807e7..5c8689a 100644 --- a/node/yarn.lock +++ b/node/yarn.lock @@ -3615,7 +3615,7 @@ stack-utils@^2.0.3: dependencies: escape-string-regexp "^2.0.0" -"stats-lite@github:vtex/node-stats-lite#dist": +stats-lite@vtex/node-stats-lite#dist: version "2.2.0" resolved "https://codeload.github.com/vtex/node-stats-lite/tar.gz/1b0d39cc41ef7aaecfd541191f877887a2044797" dependencies: From 853140d0c167b653af633bb4f84673f7c1df26eb Mon Sep 17 00:00:00 2001 From: mihainutiu-vtex Date: Tue, 5 Sep 2023 10:13:27 +0300 Subject: [PATCH 2/4] updated changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e396ee5..d3b044e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed +- Fixed issue with unauthenticated B2C users in checkout shipping step + ## [1.10.1] - 2023-08-17 ### Fixed - Fix conditional chain causing issue when retrieving Cost Center data From 98c720fd621ce1df17066124052bad17606bc690 Mon Sep 17 00:00:00 2001 From: mihainutiu-vtex Date: Tue, 5 Sep 2023 10:34:49 +0300 Subject: [PATCH 3/4] fix --- checkout-ui-custom/checkout6-custom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checkout-ui-custom/checkout6-custom.js b/checkout-ui-custom/checkout6-custom.js index 6f580b6..e970f9d 100644 --- a/checkout-ui-custom/checkout6-custom.js +++ b/checkout-ui-custom/checkout6-custom.js @@ -444,7 +444,7 @@ const MAX_TIME_EXPIRATION = 1000 * 60 * 5 // 5 minutes isWorkspace() ? `?v=${ts}` : '' }`, }).then(function (response) { - if (Object.keys(response).length === 0 || response[0] === 'User not authenticated') { + if (Object.keys(response).length === 0 || response.error === 'User not authenticated') { window.sessionStorage.removeItem('b2b-checkout-settings') return From 381faf656b051b04038d98104b1596b40edc71c0 Mon Sep 17 00:00:00 2001 From: mihainutiu-vtex Date: Mon, 9 Oct 2023 16:54:38 +0300 Subject: [PATCH 4/4] changed response code to 400 --- checkout-ui-custom/checkout6-custom.js | 5 +++++ node/resolvers/Routes/index.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/checkout-ui-custom/checkout6-custom.js b/checkout-ui-custom/checkout6-custom.js index e970f9d..29875ee 100644 --- a/checkout-ui-custom/checkout6-custom.js +++ b/checkout-ui-custom/checkout6-custom.js @@ -443,6 +443,11 @@ const MAX_TIME_EXPIRATION = 1000 * 60 * 5 // 5 minutes url: `${rootPath}/_v/private/b2b-checkout-settings/${ isWorkspace() ? `?v=${ts}` : '' }`, + error: function(err) { + window.sessionStorage.removeItem('b2b-checkout-settings') + + return + } }).then(function (response) { if (Object.keys(response).length === 0 || response.error === 'User not authenticated') { window.sessionStorage.removeItem('b2b-checkout-settings') diff --git a/node/resolvers/Routes/index.ts b/node/resolvers/Routes/index.ts index b3d2ada..638b719 100644 --- a/node/resolvers/Routes/index.ts +++ b/node/resolvers/Routes/index.ts @@ -19,7 +19,7 @@ export default { ctx.response.body = { error: 'User not authenticated', } - ctx.response.status = 200 + ctx.response.status = 400 ctx.set('cache-control', 'no-cache') } else {