From e832ff99829da3da029056cac4911ddfcf62863c Mon Sep 17 00:00:00 2001 From: Charles Garrett Date: Thu, 7 Mar 2024 16:56:21 -0500 Subject: [PATCH] fix: avoid triggering the sign-in modal if user has already authenticated --- src/pages/[componentAccountId]/widget/[componentName].tsx | 4 ++-- src/pages/applications.tsx | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pages/[componentAccountId]/widget/[componentName].tsx b/src/pages/[componentAccountId]/widget/[componentName].tsx index d744ede30..7e2392266 100644 --- a/src/pages/[componentAccountId]/widget/[componentName].tsx +++ b/src/pages/[componentAccountId]/widget/[componentName].tsx @@ -112,10 +112,10 @@ const ViewComponentPage: NextPageWithLayout = () => { useEffect(() => { const { requestAuth, createAccount } = componentProps; - if (requestAuth) { + if (requestAuth && !authStore.account) { requestAuthentication(!!createAccount); } - }, [componentProps, requestAuthentication]); + }, [authStore, componentProps, requestAuthentication]); useEffect(() => { setComponentSrc(componentSrc); diff --git a/src/pages/applications.tsx b/src/pages/applications.tsx index 047dfdada..e747eba4e 100644 --- a/src/pages/applications.tsx +++ b/src/pages/applications.tsx @@ -3,6 +3,7 @@ import { useBosComponents } from '@/hooks/useBosComponents'; import { useDefaultLayout } from '@/hooks/useLayout'; import { useEffect } from 'react'; import { useRouter } from 'next/router'; +import { useAuthStore } from '@/stores/auth'; import { useSignInRedirect } from '@/hooks/useSignInRedirect'; import type { NextPageWithLayout } from '@/utils/types'; @@ -10,13 +11,14 @@ const ApplicationsPage: NextPageWithLayout = () => { const components = useBosComponents(); const router = useRouter(); const { requestAuthentication } = useSignInRedirect(); + const authStore = useAuthStore(); useEffect(() => { const { requestAuth, createAccount } = router.query; - if (requestAuth) { + if (requestAuth && !authStore.account) { requestAuthentication(!!createAccount); } - }, [requestAuthentication, router.query]); + }, [authStore, requestAuthentication, router.query]); return (