mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-12 16:29:14 +00:00
Updated the dashabord, members, and settings pages
This commit is contained in:
@@ -397,9 +397,21 @@ export const getOrganizationMembersAndTheirWorkspaces = async (
|
||||
res: Response
|
||||
) => {
|
||||
const { organizationId } = req.params;
|
||||
const orgMemberships = await MembershipOrg.find({ organization: organizationId });
|
||||
const userIds = orgMemberships.map(orgMembership => orgMembership.user);
|
||||
const memberships = await Membership.find({ user: { $in: userIds } });
|
||||
|
||||
const workspacesSet = (
|
||||
await Workspace.find(
|
||||
{
|
||||
organization: organizationId
|
||||
},
|
||||
'_id'
|
||||
)
|
||||
).map((w) => w._id.toString());
|
||||
|
||||
const memberships = (
|
||||
await Membership.find({
|
||||
workspace: { $in: workspacesSet }
|
||||
}).populate('workspace')
|
||||
);
|
||||
const userToWorkspaceIds: any = {};
|
||||
|
||||
memberships.forEach(membership => {
|
||||
@@ -411,15 +423,5 @@ export const getOrganizationMembersAndTheirWorkspaces = async (
|
||||
}
|
||||
});
|
||||
|
||||
const workspaceIds = Object.values(userToWorkspaceIds).flat()
|
||||
const workspacesList = await Workspace.find({
|
||||
organization: organizationId,
|
||||
_id: { $in: workspaceIds }
|
||||
});
|
||||
|
||||
const populatedUserWorkspaces = _.mapValues(userToWorkspaceIds, workspaceIds =>
|
||||
_.map(workspaceIds, id => _.find(workspacesList, { _id: id }))
|
||||
);
|
||||
|
||||
return res.json(populatedUserWorkspaces);
|
||||
return res.json(userToWorkspaceIds);
|
||||
};
|
||||
@@ -246,13 +246,14 @@ export const getAllAccessibleEnvironmentsOfWorkspace = async (
|
||||
relatedWorkspace.environments.forEach(environment => {
|
||||
const isReadBlocked = _.some(deniedPermission, { environmentSlug: environment.slug, ability: ABILITY_READ })
|
||||
const isWriteBlocked = _.some(deniedPermission, { environmentSlug: environment.slug, ability: ABILITY_WRITE })
|
||||
if (isReadBlocked) {
|
||||
if (isReadBlocked && isWriteBlocked) {
|
||||
return
|
||||
} else {
|
||||
accessibleEnvironments.push({
|
||||
name: environment.name,
|
||||
slug: environment.slug,
|
||||
isWriteDenied: isWriteBlocked
|
||||
isWriteDenied: isWriteBlocked,
|
||||
isReadDenied: isReadBlocked
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user