feature/ST-1742-TK-2815-added-tenant-admin-flow#213
feature/ST-1742-TK-2815-added-tenant-admin-flow#213VISHNUDAS-tunerlabs merged 4 commits intodevelopfrom
Conversation
📝 WalkthroughWalkthroughThe changes refactor organization ID handling from array-based to scalar values across the authentication and entity management layers. The authenticator middleware simplifies the TENANT_ADMIN flow by deriving orgId directly from the decoded token's first organization code and removing prior validation checks. Entity and entity type helpers updated accordingly to treat orgId as a primitive value. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/generics/middleware/authenticator.js`:
- Around line 491-493: When extracting org for TENANT_ADMIN in the authenticator
middleware, guard access to decodedToken.data.organizations to avoid null/empty
array access and ensure the user's chosen org is persisted: check role (e.g.
TENANT_ADMIN) and if decodedToken.data.organizations exists and has elements use
decodedToken.data.organizations[0].code, otherwise fall back safely (e.g.
undefined) without throwing; also when req.body.orgId is present set
req.headers['orgid'] = req.body.orgId (not just read it) so the selected org is
honored; update the logic around the orgId assignment that currently reads
decodedToken and req.body (the lines referencing
decodedToken.data.organizations, req.headers['orgid'], and req.body.orgId) to
include these guards and the header assignment.
- Line 510: The assignment decodedToken.data.tenantAndOrgInfo['orgId'] =
req.headers['orgid'].toString() corrupts arrays into comma strings; change it to
preserve arrays or explicitly pick a single ID: check if
Array.isArray(req.headers['orgid']) then assign the array directly to
decodedToken.data.tenantAndOrgInfo['orgId'], else if you expect a single org id
wrap the string in an array (e.g. [req.headers['orgid']]) or extract the first
element; update the assignment in the authenticator middleware (the
decodedToken.data.tenantAndOrgInfo['orgId'] set used in SUPER_ADMIN / ORG_ADMIN
flows) to use this conditional logic instead of .toString().
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/generics/middleware/authenticator.jssrc/module/entities/helper.jssrc/module/entityTypes/helper.js
VISHNUDAS-tunerlabs
left a comment
There was a problem hiding this comment.
First review - Mar 3
VISHNUDAS-tunerlabs
left a comment
There was a problem hiding this comment.
Reviewed on 4 March - 2nd review
VISHNUDAS-tunerlabs
left a comment
There was a problem hiding this comment.
Approved on 24 March
Summary by CodeRabbit