feat: allow users to have access to multiple oorgs

This commit is contained in:
2025-12-01 17:26:35 +05:30
parent 06a7b961ed
commit 8241fa3eaa
17 changed files with 117 additions and 44 deletions

View File

@@ -27,7 +27,7 @@ export async function createRts(
let defaultClient = input.client;
const userInDb = await getUserWithoutPopulate(user.userId);
if (userInDb && userInDb.orgId) {
defaultClient = userInDb.orgId.toString();
defaultClient = userInDb.orgId[0].toString();
}
if (!input.stage) {
@@ -83,7 +83,11 @@ export async function listRts(
let filterObj = getFilterObject(params) || [];
if (user.role === "client") {
filterObj.push({ client: new mongoose.Types.ObjectId(user.orgId) });
filterObj.push({
client: {
$in: user.orgId.map((item) => new mongoose.Types.ObjectId(item)),
},
});
}
let { taggedFilter, taggedUserFilterIndex } = getTaggedUsersFilter(