From 4c5d66d6d1bb15c0eae479eabbd38eb054609766 Mon Sep 17 00:00:00 2001 From: guru_sainath Date: Mon, 20 May 2024 16:12:56 +0530 Subject: [PATCH] fix: onboarded steps validation in web app (#4527) --- web/lib/wrappers/authentication-wrapper.tsx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/web/lib/wrappers/authentication-wrapper.tsx b/web/lib/wrappers/authentication-wrapper.tsx index 8dfd5771a..a598d8a0e 100644 --- a/web/lib/wrappers/authentication-wrapper.tsx +++ b/web/lib/wrappers/authentication-wrapper.tsx @@ -37,6 +37,14 @@ export const AuthenticationWrapper: FC = observer((props shouldRetryOnError: false, }); + const isUserOnboard = + currentUserProfile?.is_onboarded || + (currentUserProfile?.onboarding_step?.profile_complete && + currentUserProfile?.onboarding_step?.workspace_create && + currentUserProfile?.onboarding_step?.workspace_invite && + currentUserProfile?.onboarding_step?.workspace_join) || + false; + const getWorkspaceRedirectionUrl = (): string => { let redirectionRoute = "/profile"; @@ -72,7 +80,7 @@ export const AuthenticationWrapper: FC = observer((props if (pageType === EPageTypes.NON_AUTHENTICATED) { if (!currentUser?.id) return <>{children}; else { - if (currentUserProfile?.id && currentUserProfile?.is_onboarded) { + if (currentUserProfile?.id && isUserOnboard) { const currentRedirectRoute = getWorkspaceRedirectionUrl(); router.push(currentRedirectRoute); return <>; @@ -88,7 +96,7 @@ export const AuthenticationWrapper: FC = observer((props router.push("/sign-in"); return <>; } else { - if (currentUser && currentUserProfile?.id && currentUserProfile?.is_onboarded) { + if (currentUser && currentUserProfile?.id && isUserOnboard) { const currentRedirectRoute = getWorkspaceRedirectionUrl(); router.push(currentRedirectRoute); return <>; @@ -101,12 +109,7 @@ export const AuthenticationWrapper: FC = observer((props router.push("/sign-in"); return <>; } else { - if ( - currentUser && - !currentUser?.is_password_autoset && - currentUserProfile?.id && - currentUserProfile?.is_onboarded - ) { + if (currentUser && !currentUser?.is_password_autoset && currentUserProfile?.id && isUserOnboard) { const currentRedirectRoute = getWorkspaceRedirectionUrl(); router.push(currentRedirectRoute); return <>; @@ -116,7 +119,7 @@ export const AuthenticationWrapper: FC = observer((props if (pageType === EPageTypes.AUTHENTICATED) { if (currentUser?.id) { - if (currentUserProfile && currentUserProfile?.id && currentUserProfile?.is_onboarded) return <>{children}; + if (currentUserProfile && currentUserProfile?.id && isUserOnboard) return <>{children}; else { router.push(`/onboarding`); return <>;