Added clickAwayHandler + POST functionality + Bug fixed.

This commit is contained in:
Daniel
2023-02-14 00:52:47 +03:30
parent eadf021939
commit cefeb5e7a9
6 changed files with 94 additions and 8 deletions
+5 -1
View File
@@ -18,6 +18,9 @@ export default async function handler(
) {
const body: User = req.body;
if (!body.email || !body.password || !body.name)
return res.status(400).json({ message: "Please fill out all the fields." });
const checkIfUserExists = await prisma.user.findFirst({
where: {
email: body.email,
@@ -50,7 +53,8 @@ export default async function handler(
});
res.status(201).json({ message: "User successfully created." });
} else {
} else if (checkIfUserExists) {
console.log(checkIfUserExists);
res.status(400).json({ message: "User already exists." });
}
}