From 9f5c4d3d52a2c54f3c3fde86288daba2a00037e6 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 12 Sep 2023 15:11:33 +0530 Subject: [PATCH 1/4] Fixed: the case to redefine the events passed from the app after clearing the user data --- src/components/Login.ts | 13 ++++++++++--- src/components/index.ts | 2 ++ src/index.ts | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/Login.ts b/src/components/Login.ts index 1e82536..d9279cf 100644 --- a/src/components/Login.ts +++ b/src/components/Login.ts @@ -1,5 +1,5 @@ import { defineComponent } from "vue" -import { loginContext as context, useAuthStore, appContext } from "../index" +import { loginContext as context, useAuthStore, appContext, loginContext } from "../index" import { DateTime } from "luxon" export default defineComponent({ @@ -33,8 +33,15 @@ export default defineComponent({ }, methods: { async handleUserFlow(token: string, oms: string, expirationTime: string) { - // logout to clear current user state - await context.logout() + + // fetch the current config for the user + const appConfig = loginContext.getConfig() + + // logout to clear current user state, don't mark the user as logout as we just want to clear the user data + await context.logout({ isUserUnauthorised: true }) + + // reset the config that we got from the oms-api, as on logout we clear the config of oms-api but in this case we want the config + await context.initialise(appConfig) // checking if token from launchpad has expired and redirecting there only if (+expirationTime < DateTime.now().toMillis()) { diff --git a/src/components/index.ts b/src/components/index.ts index 0879373..a0faf49 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -14,3 +14,5 @@ import '@ionic/vue/css/text-transformation.css'; import '@ionic/vue/css/flex-utils.css'; import '@ionic/vue/css/display.css'; +export { default as ProductIdentifier } from "./ProductIdentifier.vue"; + diff --git a/src/index.ts b/src/index.ts index d6177c7..27482fd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,6 +35,8 @@ export let dxpComponents = { shopifyImgContext.defaultImgUrl = options.defaultImgUrl productIdentificationContext.getProductIdentificationPref = options.getProductIdentificationPref productIdentificationContext.setProductIdentificationPref = options.setProductIdentificationPref + loginContext.getConfig = options.getConfig + loginContext.initialise = options.initialise } } From 5c43a8ca58aacb8fe33d93aa6231f03532dafaa3 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 12 Sep 2023 15:16:52 +0530 Subject: [PATCH 2/4] Removed: unwanted declaration of component, and update the comment --- src/components/Login.ts | 2 +- src/components/ProductIdentifier.vue | 72 ++++++++++++++++++++++++++++ src/components/index.ts | 2 - 3 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 src/components/ProductIdentifier.vue diff --git a/src/components/Login.ts b/src/components/Login.ts index d9279cf..c274d90 100644 --- a/src/components/Login.ts +++ b/src/components/Login.ts @@ -40,7 +40,7 @@ export default defineComponent({ // logout to clear current user state, don't mark the user as logout as we just want to clear the user data await context.logout({ isUserUnauthorised: true }) - // reset the config that we got from the oms-api, as on logout we clear the config of oms-api but in this case we want the config + // reset the config that we got from the oms-api, as on logout we clear the config of oms-api await context.initialise(appConfig) // checking if token from launchpad has expired and redirecting there only diff --git a/src/components/ProductIdentifier.vue b/src/components/ProductIdentifier.vue new file mode 100644 index 0000000..e42d9d3 --- /dev/null +++ b/src/components/ProductIdentifier.vue @@ -0,0 +1,72 @@ + + + \ No newline at end of file diff --git a/src/components/index.ts b/src/components/index.ts index a0faf49..0879373 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -14,5 +14,3 @@ import '@ionic/vue/css/text-transformation.css'; import '@ionic/vue/css/flex-utils.css'; import '@ionic/vue/css/display.css'; -export { default as ProductIdentifier } from "./ProductIdentifier.vue"; - From da759a80eba664ee03ec95da00ee5e2378b32b95 Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 12 Sep 2023 15:17:28 +0530 Subject: [PATCH 3/4] Revert "Removed: unwanted declaration of component, and update the comment" This reverts commit 5c43a8ca58aacb8fe33d93aa6231f03532dafaa3. --- src/components/Login.ts | 2 +- src/components/ProductIdentifier.vue | 72 ---------------------------- src/components/index.ts | 2 + 3 files changed, 3 insertions(+), 73 deletions(-) delete mode 100644 src/components/ProductIdentifier.vue diff --git a/src/components/Login.ts b/src/components/Login.ts index c274d90..d9279cf 100644 --- a/src/components/Login.ts +++ b/src/components/Login.ts @@ -40,7 +40,7 @@ export default defineComponent({ // logout to clear current user state, don't mark the user as logout as we just want to clear the user data await context.logout({ isUserUnauthorised: true }) - // reset the config that we got from the oms-api, as on logout we clear the config of oms-api + // reset the config that we got from the oms-api, as on logout we clear the config of oms-api but in this case we want the config await context.initialise(appConfig) // checking if token from launchpad has expired and redirecting there only diff --git a/src/components/ProductIdentifier.vue b/src/components/ProductIdentifier.vue deleted file mode 100644 index e42d9d3..0000000 --- a/src/components/ProductIdentifier.vue +++ /dev/null @@ -1,72 +0,0 @@ - - - \ No newline at end of file diff --git a/src/components/index.ts b/src/components/index.ts index 0879373..a0faf49 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -14,3 +14,5 @@ import '@ionic/vue/css/text-transformation.css'; import '@ionic/vue/css/flex-utils.css'; import '@ionic/vue/css/display.css'; +export { default as ProductIdentifier } from "./ProductIdentifier.vue"; + From ddb66b298e2bf31b543ac4d40578222277c1485c Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 12 Sep 2023 15:18:59 +0530 Subject: [PATCH 4/4] Removed: unwanted declaration of component, and update the comment --- src/components/Login.ts | 2 +- src/components/index.ts | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/Login.ts b/src/components/Login.ts index d9279cf..c274d90 100644 --- a/src/components/Login.ts +++ b/src/components/Login.ts @@ -40,7 +40,7 @@ export default defineComponent({ // logout to clear current user state, don't mark the user as logout as we just want to clear the user data await context.logout({ isUserUnauthorised: true }) - // reset the config that we got from the oms-api, as on logout we clear the config of oms-api but in this case we want the config + // reset the config that we got from the oms-api, as on logout we clear the config of oms-api await context.initialise(appConfig) // checking if token from launchpad has expired and redirecting there only diff --git a/src/components/index.ts b/src/components/index.ts index a0faf49..0879373 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -14,5 +14,3 @@ import '@ionic/vue/css/text-transformation.css'; import '@ionic/vue/css/flex-utils.css'; import '@ionic/vue/css/display.css'; -export { default as ProductIdentifier } from "./ProductIdentifier.vue"; -