Merge pull request #70 from calcom/fix/disable-users-post

fix: disable admin only post endpoint for users as makes build fail u…
pull/9078/head
Agusti Fernandez Pardo 2022-05-11 16:02:01 +02:00 committed by GitHub
commit 8f05c3e991
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 11 deletions

View File

@ -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.