Patch vulnerability that allowed self-promotion

This commit is contained in:
Alex van Andel committed 2023-04-23 18:43:23 +02:00
1 parent 37a2209871
commit 02094904be
1 file changed
+5
+5
View File
@@ -94,6 +94,11 @@ export async function patchHandler(req: NextApiRequest) {
if (!isAdmin && query.userId !== req.userId) throw new HttpError({ statusCode: 403, message: "Forbidden" });
const body = await schemaUserEditBodyParams.parseAsync(req.body);
// disable role changes unless admin.
if (!isAdmin && body.role) {
body.role = undefined;
}
const userSchedules = await prisma.schedule.findMany({
where: { userId: query.userId },
});