From 72444792bc101c45b18a96fda74fe6043a0095d4 Mon Sep 17 00:00:00 2001 From: Agusti Fernandez Pardo Date: Wed, 11 May 2022 16:01:35 +0200 Subject: [PATCH] fix: disable admin only post endpoint for users as makes build fail until impersonate PR merged into web main/prod --- pages/api/users/index.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/pages/api/users/index.ts b/pages/api/users/index.ts index 6eea24cb3b..9f80a421d2 100644 --- a/pages/api/users/index.ts +++ b/pages/api/users/index.ts @@ -40,18 +40,19 @@ async function getAllorCreateUser( message: "No Users were found", error, }); - } else if (method === "POST") { - const isAdmin = await prisma.user - .findUnique({ where: { id: userId } }) - .then((user) => user?.role === "ADMIN"); - if (!isAdmin) res.status(401).json({ message: "You are not authorized" }); - else { - const user = await prisma.user.create({ - data: schemaUserReadPublic.parse(body), - }); - res.status(201).json({ user }); - } } + // else if (method === "POST") { + // const isAdmin = await prisma.user + // .findUnique({ where: { id: userId } }) + // .then((user) => user?.role === "ADMIN"); + // if (!isAdmin) res.status(401).json({ message: "You are not authorized" }); + // else { + // const user = await prisma.user.create({ + // data: schemaUserReadPublic.parse(body), + // }); + // res.status(201).json({ user }); + // } + // } } // No POST endpoint for users for now as a regular user you're expected to signup.