Skip to content

Conversation

@nevil-mathew
Copy link
Collaborator

@nevil-mathew nevil-mathew commented Aug 6, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Improved session retrieval to ensure user sessions are matched with the correct tenant.
    • Fixed validation for bulk user creation to properly enforce allowed upload types.
  • Enhancements
    • Enhanced file upload listing with improved filtering and pagination, including tenant-specific filtering.
    • Removed default tenant code from file uploads to enforce explicit tenant assignment.

@coderabbitai
Copy link

coderabbitai bot commented Aug 6, 2025

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Caution

Review failed

The pull request is closed.

Walkthrough

The generateToken method in src/services/account.js was updated to enhance the database query for user session retrieval. Specifically, the query now includes the tenant_code from the decoded token data as an additional filter, ensuring that the session is matched for the correct tenant. Additionally, changes were made to file upload model defaults, query parameter handling, error management, and validation logic related to organization administration and bulk user creation.

Changes

Cohort / File(s) Change Summary
Account session tenant filtering
src/services/account.js
Updated the user session retrieval logic in generateToken to include tenant_code in the query criteria, ensuring tenant-specific session matching.
FileUpload model and query updates
src/database/models/fileUpload.js, src/database/queries/fileUpload.js
Removed default empty string from tenant_code in model; changed import path to absolute alias; updated error handling to throw exceptions; refactored listUploads to accept a single object parameter with flexible filtering and simplified pagination; streamlined query results to return raw objects.
Org-admin service pagination and filtering
src/services/org-admin.js
Modified getBulkInvitesFilesList to call listUploads with a single object parameter containing pagination and a filter object that now includes tenant_code.
Validation fix for bulk user creation
src/validators/v1/org-admin.js
Fixed .isIn() validator call by passing the required upload_type array argument to properly validate the upload_type field in bulkUserCreate.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Possibly related PRs

Poem

In the warren of code, a tenant now found,
Sessions are filtered, safe and sound.
With tenant_code snug in the query’s embrace,
Each user’s session finds its rightful place.
Filters refined, validations tight,
This rabbit hops with pure delight! 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 2f4fd26 and 785daa3.

📒 Files selected for processing (4)
  • src/database/models/fileUpload.js (0 hunks)
  • src/database/queries/fileUpload.js (3 hunks)
  • src/services/org-admin.js (1 hunks)
  • src/validators/v1/org-admin.js (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch admin-create-api

🪧 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.
  • 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.

Support

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

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 generate unit tests to generate unit tests for 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.

@nevil-mathew
Copy link
Collaborator Author

@coderabbitai pause

@coderabbitai
Copy link

coderabbitai bot commented Aug 6, 2025

✅ Actions performed

Reviews paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants