Skip to content

Commit 2666839

Browse files
Merge pull request #146 from PeerPrep/update-users-service
Edit endpoint
2 parents 38a77e3 + 4af6f68 commit 2666839

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

users/src/admin/update.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ export async function updateRoleHandler(req: Request, res: Response) {
1515
});
1616
}
1717

18-
const loadedProfile = await em.findOneOrFail(Profile, {
19-
uid: body.uid,
20-
});
21-
22-
loadedProfile.role = body.role;
18+
const loadedProfiles = await em.find(Profile, { uid: { $in: body.uids } });
19+
for (const profile of loadedProfiles) {
20+
profile.role = body.role;
21+
}
2322

2423
await em.flush();
2524

@@ -28,7 +27,7 @@ export async function updateRoleHandler(req: Request, res: Response) {
2827
message: "Role updated successfully",
2928
type: StatusMessageType.SUCCESS,
3029
},
31-
payload: loadedProfile,
30+
payload: loadedProfiles,
3231
};
3332
res.status(200).send(response);
3433
} catch (err: any) {

0 commit comments

Comments
 (0)