Skip to content

Commit f4888c9

Browse files
committed
fix: Restore UserPermissionSearch click to assign userToEdit
1 parent 9e447d0 commit f4888c9

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

backend/controllers/user.controller.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,24 @@ UserController.projectManager_list = async function (req, res) {
5353

5454
try {
5555
const projectManagers = await User.find({
56-
$and: [
57-
{ accessLevel: { $in: ['admin', 'superadmin'] } },
58-
{ managedProjects: { $exists: true, $type: 'array', $ne: [] } },
59-
],
56+
managedProjects: { $exists: true, $type: 'array', $ne: [] },
6057
});
6158

6259
// Collect all unique project IDs
63-
const allProjectIds = [...new Set(projectManagers.flatMap((pm) => pm.managedProjects))];
60+
const allProjectIds = [
61+
...new Set(
62+
projectManagers
63+
.flatMap((pm) => pm.managedProjects)
64+
.filter((id) => typeof id === 'string' && id.match(/^[a-f\d]{24}$/i)),
65+
),
66+
];
6467

6568
// Fetch all projects in one query
66-
const projects = await Project.find({ _id: { $in: allProjectIds } });
69+
const projects = await Project.find(
70+
{ _id: { $in: allProjectIds } },
71+
{ _id: 1, name: 1 }, // projection
72+
);
73+
6774
const projectIdToName = {};
6875
for (const project of projects) {
6976
projectIdToName[project._id.toString()] = project.name;

0 commit comments

Comments
 (0)