Skip to content

fix: handle undefined user object in LandingScreen for non-existent cloud billing domains #40855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2025

Conversation

jacquesikot
Copy link
Contributor

@jacquesikot jacquesikot commented Jun 4, 2025

Problem

With the introduction of cloud billing and multi-organization support, users can now access Appsmith through organization-specific subdomains (e.g., testorg.appsmith.com). However, when users attempt to access non-existent domains (e.g., domaindoesnotexist.appsmith.com), the system fails to return a user object, causing the application to get stuck in an infinite loading state.

🔍 Root Cause

The issue was in the LandingScreen component's conditional logic:

// Previous implementation ❌
if (props.user && window.location.pathname === BASE_URL) {
  if (props.user.email === ANONYMOUS_USERNAME) {
    return <Redirect to={AUTH_LOGIN_URL} />;
  } else {
    return <Redirect to={APPLICATIONS_URL} />;
  }
}

The problem: When accessing a non-existent domain, props.user is null/undefined, causing the condition props.user && window.location.pathname === BASE_URL to evaluate to false. This prevented the redirect logic from executing, leaving users on a perpetual loading screen instead of being properly redirected to the login page.

✅ Solution

Updated the conditional logic to handle cases where the user object is undefined:

// Fixed implementation ✅
if (window.location.pathname === BASE_URL) {
  if (!props.user || props.user.email === ANONYMOUS_USERNAME) {
    return <Redirect to={AUTH_LOGIN_URL} />;
  } else {
    return <Redirect to={APPLICATIONS_URL} />;
  }
}

Key changes:

  1. Removed the props.user && guard condition - Now the redirect logic always executes when on the base URL
  2. Added explicit null/undefined check - The condition !props.user || props.user.email === ANONYMOUS_USERNAME properly handles both scenarios:
    • When no user object exists (non-existent domains)
    • When the user is anonymous

📊 Impact

Scenario Before After
Valid org domain + authenticated user ✅ Redirects to applications ✅ Redirects to applications
Valid org domain + anonymous user ✅ Redirects to login ✅ Redirects to login
Non-existent org domain Infinite loading screen Redirects to login
Direct access to login URL ✅ Works as expected ✅ Works as expected

🧪 Testing Scenarios

This fix addresses the following scenarios in the cloud billing multi-org environment:

  • Valid organization domain with authenticated user → Redirects to applications
  • Valid organization domain with anonymous user → Redirects to login
  • Non-existent organization domain → Redirects to login (instead of infinite loading)
  • Direct access to login URL → Works as expected

Automation

/ok-to-test tags="@tag.Authentication, @tag.Sanity"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/15438685266
Commit: afee6b1
Cypress dashboard.
Tags: @tag.Authentication, @tag.Sanity
Spec:


Wed, 04 Jun 2025 10:09:08 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • Bug Fixes
    • Improved user redirection on the landing screen to ensure users are correctly routed based on their authentication status.

@jacquesikot jacquesikot self-assigned this Jun 4, 2025
Copy link
Contributor

coderabbitai bot commented Jun 4, 2025

Walkthrough

The conditional logic in the LandingScreen component was updated to alter the criteria for redirecting users on the base URL path. The redirect to the login URL now triggers if there is no user or if the user is anonymous, while the redirect to the applications URL remains unchanged.

Changes

File(s) Change Summary
app/client/src/LandingScreen.tsx Modified conditional logic for redirecting users based on user existence and anonymity status.

Suggested labels

Bug, ok-to-test

Suggested reviewers

  • ankitakinger
  • trishaanand

Poem

On the landing screen, a logic twist,
Redirects now catch what once they missed.
If users vanish or hide their name,
To login they go, all just the same.
With code refined and pathways clear,
The journey starts—no need to fear!
🚀


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 69d6ffd and afee6b1.

📒 Files selected for processing (1)
  • app/client/src/LandingScreen.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
app/client/src/LandingScreen.tsx (1)
app/client/src/constants/routes/baseRoutes.ts (1)
  • BASE_URL (4-4)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (1)
app/client/src/LandingScreen.tsx (1)

18-19: LGTM! Clean fix for the undefined user issue.

The conditional logic correctly addresses the infinite loading problem. By checking !props.user first, you ensure that users accessing non-existent domains (where the user object is null/undefined) are properly redirected to the login page instead of hanging.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the Bug Something isn't working label Jun 4, 2025
@jacquesikot jacquesikot added the ok-to-test Required label for CI label Jun 4, 2025
@jacquesikot jacquesikot merged commit 3d7a99e into release Jun 4, 2025
48 checks passed
@jacquesikot jacquesikot deleted the fix/multi-org-login-landing-screen-error branch June 4, 2025 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working ok-to-test Required label for CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants