Skip to content

Commit

Permalink
fix: onboarded steps validation in web app (#4527)
Browse files Browse the repository at this point in the history
  • Loading branch information
gurusainath committed May 20, 2024
1 parent 1355873 commit 4c5d66d
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions web/lib/wrappers/authentication-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export const AuthenticationWrapper: FC<TAuthenticationWrapper> = 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";

Expand Down Expand Up @@ -72,7 +80,7 @@ export const AuthenticationWrapper: FC<TAuthenticationWrapper> = 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 <></>;
Expand All @@ -88,7 +96,7 @@ export const AuthenticationWrapper: FC<TAuthenticationWrapper> = 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 <></>;
Expand All @@ -101,12 +109,7 @@ export const AuthenticationWrapper: FC<TAuthenticationWrapper> = 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 <></>;
Expand All @@ -116,7 +119,7 @@ export const AuthenticationWrapper: FC<TAuthenticationWrapper> = 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 <></>;
Expand Down

0 comments on commit 4c5d66d

Please sign in to comment.