Skip to content

Conversation

@YashodhanJoshi1
Copy link
Contributor

This squashes the commits from the main PR (#9416) for the release branch.

commit dd70a36
Author: omkark06 <[email protected]>
Date:   Tue Dec 9 11:50:42 2025 +0530

    fix: signout if verifyuser api fails

commit 93caae0
Author: omkark06 <[email protected]>
Date:   Tue Dec 9 11:26:43 2025 +0530

    fix: logout user when organizations api fails with 403

commit 86e67c3
Author: omkark06 <[email protected]>
Date:   Mon Dec 8 18:12:22 2025 +0530

    fix: fetch pending invites on login to check if invites exists

commit c81a1e7
Author: sai nikhil kethe <[email protected]>
Date:   Mon Dec 8 13:24:31 2025 +0530

    fix: ui unit test cases

commit 0903865
Author: sai nikhil kethe <[email protected]>
Date:   Mon Dec 8 12:02:50 2025 +0530

    fix: invitationList as per updated UI theme

commit 6e45401
Merge: 4bdc0b4 5045e3a
Author: Yashodhan Joshi <[email protected]>
Date:   Mon Dec 8 10:04:25 2025 +0530

    Merge branch 'main' into fix/cloud_orgs

commit 4bdc0b4
Merge: 40a21e1 6e857ea
Author: Yashodhan Joshi <[email protected]>
Date:   Tue Dec 2 11:13:53 2025 +0530

    Merge branch 'main' into fix/cloud_orgs

commit 40a21e1
Author: Yashodhan Joshi <[email protected]>
Date:   Tue Dec 2 10:55:55 2025 +0530

    fix: geenrate token in invite addition

    Signed-off-by: Yashodhan Joshi <[email protected]>

commit 73a9236
Author: sai nikhil kethe <[email protected]>
Date:   Mon Dec 1 18:14:34 2025 +0530

    fix: refresh the list after succesfull invite

commit 37d0e78
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Mon Dec 1 12:41:28 2025 +0000

    chore: update translations from en.json

    Auto-generated translation updates from English source file.

    🤖 Generated with automated translation workflow

commit 07d27a0
Author: sai nikhil kethe <[email protected]>
Date:   Mon Dec 1 18:11:02 2025 +0530

    fix: revoke method added for invites

commit 3200478
Author: Yashodhan Joshi <[email protected]>
Date:   Mon Dec 1 17:33:05 2025 +0530

    fix: sent token in the invites api

    Signed-off-by: Yashodhan Joshi <[email protected]>

commit d7ac784
Author: sai nikhil kethe <[email protected]>
Date:   Mon Dec 1 16:46:35 2025 +0530

    fix: trail period message change

commit 4cce5cd
Author: sai nikhil kethe <[email protected]>
Date:   Mon Dec 1 16:27:14 2025 +0530

    fix: should show the role in capital letter

commit 99ec65e
Author: sai nikhil kethe <[email protected]>
Date:   Mon Dec 1 16:22:25 2025 +0530

    fix: show error if same email id sent for invite

commit 237bac4
Author: sai nikhil kethe <[email protected]>
Date:   Mon Dec 1 16:18:39 2025 +0530

    fix: shows search input , dedup emails ids

commit 85ac4bd
Author: sai nikhil kethe <[email protected]>
Date:   Mon Dec 1 15:13:25 2025 +0530

    fix: merge conflicts in user.vue

commit bc31ad7
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Mon Dec 1 09:42:15 2025 +0000

    chore: update translations from en.json

    Auto-generated translation updates from English source file.

    🤖 Generated with automated translation workflow

commit 2b8a82a
Merge: 0d7b2a2 4ecc550
Author: sai nikhil kethe <[email protected]>
Date:   Mon Dec 1 15:11:45 2025 +0530

    Merge branch 'main' into fix/cloud_orgs

commit 0d7b2a2
Author: Yashodhan Joshi <[email protected]>
Date:   Fri Oct 3 10:19:57 2025 +0530

    fix: check domain on invite also

    Signed-off-by: Yashodhan Joshi <[email protected]>

commit f8c47eb
Merge: 193fd67 9d357d0
Author: Yashodhan Joshi <[email protected]>
Date:   Fri Oct 3 10:24:30 2025 +0530

    Merge branch 'main' into fix/cloud_orgs

    Signed-off-by: Yashodhan Joshi <[email protected]>

commit 193fd67
Author: omkark06 <[email protected]>
Date:   Mon Sep 22 11:14:51 2025 +0530

    fix: removed empty tag

commit b8299f7
Merge: d42f30a 83663f6
Author: Yashodhan Joshi <[email protected]>
Date:   Mon Sep 22 10:45:48 2025 +0530

    Merge branch 'main' into fix/cloud_orgs

commit d42f30a
Merge: b65e868 d40b6af
Author: Yashodhan Joshi <[email protected]>
Date:   Thu Sep 18 14:31:40 2025 +0530

    Merge branch 'main' into fix/cloud_orgs

commit b65e868
Author: omkark06 <[email protected]>
Date:   Fri Sep 5 16:25:14 2025 +0530

    fix: Invitations in IAM

commit f560b06
Author: Yashodhan Joshi <[email protected]>
Date:   Thu Sep 4 11:50:01 2025 +0530

    fix: allow user to only be part of one free org via invitation

    Signed-off-by: Yashodhan Joshi <[email protected]>

commit 7233af3
Author: Yashodhan Joshi <[email protected]>
Date:   Wed Sep 3 16:50:00 2025 +0530

    feat: create new org for new user after all invitation decline

    Signed-off-by: Yashodhan Joshi <[email protected]>

Signed-off-by: Yashodhan Joshi <[email protected]>
@github-actions github-actions bot added the ☢️ Bug Something isn't working label Dec 10, 2025
@github-actions
Copy link
Contributor

Failed to generate code suggestions for PR

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 10, 2025

Greptile Overview

Greptile Summary

Adds comprehensive organization invitation management for cloud deployments, including UI for viewing/accepting/declining invitations, admin ability to revoke invites, and backend validation to prevent users from joining multiple free organizations.

Key Changes

  • Added billing checks to prevent users from being part of multiple free organizations
  • Created new /invitations route and dedicated UI page for managing pending invitations
  • Added revoke invitation functionality for admins in User management
  • Auto-creates organization for users who decline all invitations (fallback behavior)
  • Removed invitation token from email body function signature
  • Enhanced invitation list with pagination and improved styling
  • Added token field to OrganizationInviteUserRecord for tracking
  • Updated login flow to check for pending invitations via API instead of URL callback
  • Added localization support across 11 languages for new invitation features

Issues Found

  • Error handling in decline_invitation handler could leave users in inconsistent state if get_db_user fails
  • Discarded error variable in check_email call (style issue)

Confidence Score: 4/5

  • This PR is mostly safe to merge with one logic issue that should be addressed
  • The PR implements a comprehensive invitation management system with proper billing validation. Most code changes are well-structured with good error handling. However, there's a logic issue in the decline_invitation handler where a failure to get user details could leave users in an inconsistent state. The backend billing validation logic is complex and adds multiple database calls, which could impact performance but is necessary for the business logic. Frontend changes are clean and follow existing patterns.
  • src/handler/http/request/users/mod.rs requires attention for the error handling logic in decline_invitation

Important Files Changed

File Analysis

Filename Score Overview
src/handler/http/request/users/mod.rs 4/5 Enhanced decline_invitation to create org for users with no remaining invites
src/service/organization.rs 3/5 Added billing checks to prevent multiple free orgs per user; removed token from email body function signature
web/src/components/iam/users/InvitationList.vue 5/5 Redesigned UI with pagination, improved styling, and better error handling
web/src/components/iam/users/User.vue 5/5 Added revoke invite functionality with confirmation dialog and proper error handling
web/src/views/Invitations.vue 5/5 New view component for managing user invitations with proper routing
web/src/views/Login.vue 4/5 Improved invitation check using API call instead of URL callback; added signout export

Sequence Diagram

sequenceDiagram
    participant User
    participant Login
    participant InvitationList
    participant Backend
    participant BillingService
    participant Database

    User->>Login: Login to system
    Login->>Backend: getPendingInvites()
    Backend->>Database: Query pending invites
    Database-->>Backend: Return invites
    Backend-->>Login: Return invites list
    alt Has pending invites
        Login->>InvitationList: Show invitations page
        InvitationList->>User: Display pending invites
    else No pending invites
        Login->>User: Redirect to org
    end

    User->>InvitationList: Accept invitation
    InvitationList->>Backend: acceptInvitation(token)
    Backend->>BillingService: Check if org is free
    alt Org is free
        Backend->>Database: Check user's existing orgs
        Database-->>Backend: Return user orgs
        Backend->>BillingService: Validate no other free orgs
        BillingService-->>Backend: Validation result
    end
    alt Validation passes
        Backend->>Database: Add user to org
        Backend->>Database: Update invite status
        Database-->>Backend: Success
        Backend-->>InvitationList: Success
        InvitationList->>User: Redirect to org
    else Validation fails
        Backend-->>InvitationList: Error (multiple free orgs)
        InvitationList->>User: Show error
    end

    User->>InvitationList: Decline invitation
    InvitationList->>Backend: declineInvitation(token)
    Backend->>Database: Update invite to rejected
    Backend->>Database: Get remaining invites
    Database-->>Backend: Return remaining invites
    alt No remaining invites
        Backend->>Backend: Create new org for user
        Backend->>Database: Add user to new org
    end
    Backend-->>InvitationList: Return remaining count
    InvitationList->>User: Update UI

    User->>User: Admin revokes invite
    User->>Backend: revokeInvite(token)
    Backend->>Database: Delete invitation
    Database-->>Backend: Success
    Backend-->>User: Confirmation
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

27 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

}
}

if let Err(_) = o2_enterprise::enterprise::cloud::email::check_email(invitee).await {
Copy link
Contributor

Choose a reason for hiding this comment

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

style: discarded error from check_email

Suggested change
if let Err(_) = o2_enterprise::enterprise::cloud::email::check_email(invitee).await {
if let Err(e) = o2_enterprise::enterprise::cloud::email::check_email(invitee).await {
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/service/organization.rs
Line: 550:550

Comment:
**style:** discarded error from `check_email`

```suggestion
        if let Err(e) = o2_enterprise::enterprise::cloud::email::check_email(invitee).await {
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +870 to +888
if remaining.is_empty() {
// if there are no remaining invitations, create a new org for the user
let db_user = match db::user::get_db_user(user_id).await {
Ok(v) => v,
Err(e) => {
log::error!("error getting db user for {user_id} : {e}");
return Ok(HttpResponse::Ok().json(serde_json::json!({
"message":"Invitation declined successfully",
"remaining": remaining.len()
}
)));
}
};
let _ = jwt::check_and_add_to_org(
user_id,
&format!("{} {}", db_user.first_name, db_user.last_name),
)
.await;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: check user exists before auto-creating org; if get_db_user fails, function returns without logging out user who declined all invitations, leaving them in inconsistent state

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/handler/http/request/users/mod.rs
Line: 870:888

Comment:
**logic:** check user exists before auto-creating org; if `get_db_user` fails, function returns without logging out user who declined all invitations, leaving them in inconsistent state

How can I resolve this? If you propose a fix, please make it concise.

@YashodhanJoshi1 YashodhanJoshi1 merged commit c5d7d79 into branch-v0.30.0 Dec 10, 2025
38 checks passed
@YashodhanJoshi1 YashodhanJoshi1 deleted the fix/cloud_orgs_v30 branch December 10, 2025 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☢️ Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants