Skip to content

chore: Client side changes to send organizationId in verify email flow#39898

Merged
trishaanand merged 5 commits intoreleasefrom
chore/verify-email-client
Mar 25, 2025
Merged

chore: Client side changes to send organizationId in verify email flow#39898
trishaanand merged 5 commits intoreleasefrom
chore/verify-email-client

Conversation

@trishaanand
Copy link
Contributor

@trishaanand trishaanand commented Mar 25, 2025

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=""

🔍 Cypress test results

Warning

Tests have not run on the HEAD a1634ec yet


Tue, 25 Mar 2025 09:26:39 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Introduced a session token validation step during initialization to ensure the app handles token issues gracefully.
    • Enhanced error management during startup, allowing the app to continue loading smoothly even if session token validation encounters problems.
    • Added a dedicated utility for managing session tokens extracted from URL parameters.
    • Expanded the VerifyUser component to accept an additional organizationId property for improved user authentication.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 25, 2025

Walkthrough

This pull request introduces session token validation in the client’s initialization flow. The eagerPageInitSaga now calls a new validateSessionToken function, which checks for the presence of a session token in the URL and validates it via an API call. Errors during validation are caught, logged, and reported using Sentry, ensuring that the initialization process continues even if token validation fails. A new utility file provides the constant for the session token parameter and the async validation function.

Changes

File(s) Change Summary
app/.../sagas/InitSagas.ts Added a try-catch in eagerPageInitSaga to call validateSessionToken, logging errors and capturing exceptions with Sentry on failure.
app/.../utils/SessionUtils.ts Created a new file defining SESSION_TOKEN_PARAM and an async validateSessionToken function that validates the token via an API call and removes it from the URL.
app/.../pages/UserAuth/VerifyUser.tsx Added a new property organizationId to the props of the VerifyUser component.

Sequence Diagram(s)

sequenceDiagram
    participant Saga as EagerPageInitSaga
    participant Utils as SessionUtils
    participant API as Token Validation API
    participant Sentry as Sentry Logger

    Saga->>Utils: Call validateSessionToken()
    alt Session token exists
        Utils->>API: Validate session token
        alt API returns success
            API-->>Utils: Success response
            Utils->>Saga: Return true (token removed)
        else API returns error/invalid
            API-->>Utils: Error response
            Utils->>Saga: Return false
        end
    else Session token missing
        Utils->>Saga: Return false
    end
    alt Exception thrown in Utils
       Saga->>Sentry: captureException(error)
       Saga->>log: log.error(error)
    end
Loading

Suggested labels

ok-to-test

Suggested reviewers

  • sharat87
  • nidhi-nair
  • abhvsn

Poem

In our code's vibrant domain, a token takes flight,
Validated with precision, shining ever so bright.
Errors now caught with a vigilant grace,
While Sentry keeps watch over every case.
Cheers to clean sagas and tokens set right!


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 3da7db8 and a1634ec.

📒 Files selected for processing (1)
  • app/client/src/pages/UserAuth/VerifyUser.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (1)
app/client/src/pages/UserAuth/VerifyUser.tsx (1)

16-16: LGTM: Type augmentation for organizationId parameter.

The addition of organizationId to the component props correctly extends the type definition to match the expected URL parameters. The existing implementation already handles all query parameters generically, so no additional changes are required to process this new parameter.


🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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 skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Mar 25, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
app/client/src/pages/UserAuth/VerifyUser.tsx (1)

53-64: Improved form input handling with explicit fields.

The refactoring from iterating over query parameters to explicitly defining inputs is a cleaner implementation. It provides better control over which parameters are sent in the form submission.

Consider storing the redirectUrl value in a variable similar to email, token, and organizationId to avoid multiple calls to queryParams.get().

  const token = queryParams.get("token");
  const email = queryParams.get("email");
  const organizationId = queryParams.get("organizationId");
+ const redirectUrl = queryParams.get("redirectUrl");

  // Later in the JSX
- {queryParams.get("redirectUrl") && (
+ {redirectUrl && (
    <input
      name="redirectUrl"
      type="hidden"
-     value={queryParams.get("redirectUrl") || ""}
+     value={redirectUrl || ""}
    />
  )}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e08c65e and d6580e6.

📒 Files selected for processing (1)
  • app/client/src/pages/UserAuth/VerifyUser.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (1)
app/client/src/pages/UserAuth/VerifyUser.tsx (1)

22-22: Added new query parameter retrieval for organizationId.

This change correctly adds extraction of the organizationId from query parameters, aligning with the PR objective to include organizationId in the verify email flow.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
app/client/src/utils/SessionUtils.ts (1)

12-19: Use the defined constant instead of string literal

The function should use the SESSION_TOKEN_PARAM constant instead of the hardcoded string.

    const urlParams = new URLSearchParams(window.location.search);
-   const sessionToken = urlParams.get("sessionToken");
+   const sessionToken = urlParams.get(SESSION_TOKEN_PARAM);
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between d6580e6 and 3da7db8.

📒 Files selected for processing (2)
  • app/client/src/sagas/InitSagas.ts (2 hunks)
  • app/client/src/utils/SessionUtils.ts (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
app/client/src/sagas/InitSagas.ts (1)
app/client/src/utils/SessionUtils.ts (1)
  • validateSessionToken (12-42)
🔇 Additional comments (7)
app/client/src/sagas/InitSagas.ts (2)

95-95: Import validation utility from SessionUtils

Good addition of the import statement for the session token validation functionality.


466-473: Properly handle session token validation errors

The try-catch block correctly validates the session token while ensuring errors don't block initialization. Good use of error logging and Sentry for error tracking.

app/client/src/utils/SessionUtils.ts (5)

1-4: Good module structure with clear constant definition

The imports and constant definition are well-organized.


6-11: Well-documented function with clear JSDoc

The JSDoc comments clearly explain the purpose and return value of the function.


31-39: Good URL handling with proper state management

Properly removing the session token from the URL after validation is a good security practice.


39-42: Robust error handling

The catch block appropriately handles any errors during the validation process by returning false, ensuring the application flow isn't disrupted.


21-29:

Details

✅ Verification successful

Verify the API response type conversion

The type assertion being used here suggests a potential mismatch between the API response and the expected type.


🏁 Script executed:

#!/bin/bash
# Description: Check the API response type for session validation endpoint

# Find the API response type definition
rg -A 5 "ApiResponse.*boolean" --type ts

Length of output: 1208


API Response Conversion Verified
The type conversion in SessionUtils.ts is consistent with its usage throughout the codebase (see similar patterns in JSLibrarySaga.ts and GitSyncSagas.ts). The double assertion through unknown to ApiResponse<boolean> is intentional to bridge the untyped API response without causing type conflicts. No changes are needed here.

@github-actions
Copy link

🔴🔴🔴 Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 1, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

You can view the dependency diff in the run log. Look for the check-cyclic-dependencies job in the run.

@github-actions
Copy link

🔴🔴🔴 Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 1, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

You can view the dependency diff in the run log. Look for the check-cyclic-dependencies job in the run.

@trishaanand trishaanand merged commit 3e7b933 into release Mar 25, 2025
18 of 20 checks passed
@trishaanand trishaanand deleted the chore/verify-email-client branch March 25, 2025 11:18
hetunandu pushed a commit that referenced this pull request Mar 26, 2025
#39898)

## 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=""

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!WARNING]
> Tests have not run on the HEAD
a1634ec yet
> <hr>Tue, 25 Mar 2025 09:26:39 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced a session token validation step during initialization to
ensure the app handles token issues gracefully.
- Enhanced error management during startup, allowing the app to continue
loading smoothly even if session token validation encounters problems.
- Added a dedicated utility for managing session tokens extracted from
URL parameters.
- Expanded the `VerifyUser` component to accept an additional
`organizationId` property for improved user authentication.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Albin <albin@appsmith.com>
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Apr 12, 2025
appsmithorg#39898)

## 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=""

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!WARNING]
> Tests have not run on the HEAD
a1634ec yet
> <hr>Tue, 25 Mar 2025 09:26:39 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced a session token validation step during initialization to
ensure the app handles token issues gracefully.
- Enhanced error management during startup, allowing the app to continue
loading smoothly even if session token validation encounters problems.
- Added a dedicated utility for managing session tokens extracted from
URL parameters.
- Expanded the `VerifyUser` component to accept an additional
`organizationId` property for improved user authentication.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Albin <albin@appsmith.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Adding this label to a PR prevents it from being listed in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants