From f99bfda88b4b231d2c2c1b48fd3e7fdab51a5b03 Mon Sep 17 00:00:00 2001 From: Joel Jacob Stephen <70131076+JoelJacobStephen@users.noreply.github.com> Date: Tue, 5 Mar 2024 09:17:50 +0530 Subject: [PATCH] refactor: code improvements in axiosConfig, config handler and auth helper --- .../src/composables/useConfigHandler.ts | 9 +++------ packages/hoppscotch-sh-admin/src/helpers/auth.ts | 2 +- packages/hoppscotch-sh-admin/src/helpers/axiosConfig.ts | 1 + 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/hoppscotch-sh-admin/src/composables/useConfigHandler.ts b/packages/hoppscotch-sh-admin/src/composables/useConfigHandler.ts index 7aaaf18ea..1a599ecb8 100644 --- a/packages/hoppscotch-sh-admin/src/composables/useConfigHandler.ts +++ b/packages/hoppscotch-sh-admin/src/composables/useConfigHandler.ts @@ -173,12 +173,9 @@ export function useConfigHandler(updatedConfigs?: Config) { }, dataSharingConfigs: { name: 'data_sharing', - enabled: - infraConfigs.value.find( - (x) => x.name === 'ALLOW_ANALYTICS_COLLECTION' - )?.value === 'true' - ? true - : false, + enabled: !!infraConfigs.value.find( + (x) => x.name === 'ALLOW_ANALYTICS_COLLECTION' && x.value === 'true' + ), }, }; diff --git a/packages/hoppscotch-sh-admin/src/helpers/auth.ts b/packages/hoppscotch-sh-admin/src/helpers/auth.ts index ca36e7f0a..8c54050bf 100644 --- a/packages/hoppscotch-sh-admin/src/helpers/auth.ts +++ b/packages/hoppscotch-sh-admin/src/helpers/auth.ts @@ -244,7 +244,7 @@ export const auth = { getFirstTimeInfraSetupStatus: async (): Promise => { try { const res = await authQuery.getFirstTimeInfraSetupStatus(); - return res.data?.value === 'true' ? true : false; + return res.data?.value === 'true'; } catch (err) { // Setup is not done return true; diff --git a/packages/hoppscotch-sh-admin/src/helpers/axiosConfig.ts b/packages/hoppscotch-sh-admin/src/helpers/axiosConfig.ts index 8f9eecf53..a250d8c76 100644 --- a/packages/hoppscotch-sh-admin/src/helpers/axiosConfig.ts +++ b/packages/hoppscotch-sh-admin/src/helpers/axiosConfig.ts @@ -19,6 +19,7 @@ const restApi = axios.create({ const listmonkApi = axios.create({ ...baseConfig, + withCredentials: false, baseURL: 'https://listmonk.hoppscotch.com/api/public', });