From 2c0e6089468d76a54a4eef7f40292a863a600396 Mon Sep 17 00:00:00 2001 From: albinAppsmith <87797149+albinAppsmith@users.noreply.github.com> Date: Wed, 2 Apr 2025 09:29:38 +0530 Subject: [PATCH] fix: login domain redirect blocking to application (#40017) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description > [!TIP] > _Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team)._ > > _Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR._ Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.Sanity" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: cabf08853025dffdaaa5de33924e6d8fe9493c3d > Cypress dashboard. > Tags: `@tag.Sanity` > Spec: >
Tue, 01 Apr 2025 12:50:05 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **New Features** - Improved the post-signup flow by adjusting the redirection behavior based on whether the user is on the login page. - Introduced organizational context detection to ensure users are navigated to the appropriate destination after signup. --- .../src/ce/selectors/organizationSelectors.tsx | 3 +++ app/client/src/ce/utils/signupHelpers.ts | 5 ++++- app/client/src/pages/setup/SignupSuccess.tsx | 16 ++++++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/client/src/ce/selectors/organizationSelectors.tsx b/app/client/src/ce/selectors/organizationSelectors.tsx index 15f96c7a17..4f5b19cc3a 100644 --- a/app/client/src/ce/selectors/organizationSelectors.tsx +++ b/app/client/src/ce/selectors/organizationSelectors.tsx @@ -62,3 +62,6 @@ export const getHideWatermark = (state: AppState): boolean => // eslint-disable-next-line @typescript-eslint/no-unused-vars export const isFreePlan = (state: AppState) => true; + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export const isWithinAnOrganization = (state: AppState) => true; diff --git a/app/client/src/ce/utils/signupHelpers.ts b/app/client/src/ce/utils/signupHelpers.ts index 36cf087cb4..7cb745ab6e 100644 --- a/app/client/src/ce/utils/signupHelpers.ts +++ b/app/client/src/ce/utils/signupHelpers.ts @@ -28,6 +28,7 @@ export const redirectUserAfterSignup = ( // eslint-disable-next-line @typescript-eslint/no-explicit-any dispatch?: any, isEnabledForCreateNew?: boolean, // is Enabled for only non-invited users + isOnLoginPage?: boolean, // TODO: Fix this the next time the file is edited // eslint-disable-next-line @typescript-eslint/no-explicit-any ): any => { @@ -100,7 +101,9 @@ export const redirectUserAfterSignup = ( error("Error handling the redirect url"); } } else { - history.replace(APPLICATIONS_URL); + if (!isOnLoginPage) { + history.replace(APPLICATIONS_URL); + } } }; diff --git a/app/client/src/pages/setup/SignupSuccess.tsx b/app/client/src/pages/setup/SignupSuccess.tsx index 3efe3f6ff3..5508b7177c 100644 --- a/app/client/src/pages/setup/SignupSuccess.tsx +++ b/app/client/src/pages/setup/SignupSuccess.tsx @@ -8,7 +8,10 @@ import { getCurrentUser } from "selectors/usersSelectors"; import UserWelcomeScreen from "pages/setup/UserWelcomeScreen"; import { Center } from "pages/setup/common"; import { Spinner } from "@appsmith/ads"; -import { isValidLicense } from "ee/selectors/organizationSelectors"; +import { + isValidLicense, + isWithinAnOrganization, +} from "ee/selectors/organizationSelectors"; import { redirectUserAfterSignup } from "ee/utils/signupHelpers"; import { setUserSignedUpFlag } from "utils/storage"; import AnalyticsUtil from "ee/utils/AnalyticsUtil"; @@ -22,6 +25,7 @@ export function SignupSuccess() { ); const validLicense = useSelector(isValidLicense); const user = useSelector(getCurrentUser); + const isOnLoginPage = !useSelector(isWithinAnOrganization); useEffect(() => { user?.email && setUserSignedUpFlag(user?.email); @@ -37,8 +41,16 @@ export function SignupSuccess() { validLicense, dispatch, isNonInvitedUser, + isOnLoginPage, ), - [], + [ + dispatch, + isNonInvitedUser, + isOnLoginPage, + redirectUrl, + shouldEnableFirstTimeUserOnboarding, + validLicense, + ], ); const onGetStarted = useCallback((proficiency?: string, useCase?: string) => {