added toasts popups + improved login/signup page + many more changes and improvements

This commit is contained in:
Daniel
2023-06-27 02:03:40 +03:30
parent 0ddd9079bf
commit f1bd48be83
28 changed files with 464 additions and 199 deletions
-2
View File
@@ -19,8 +19,6 @@ export const authOptions: AuthOptions = {
password: string;
};
console.log(email, password);
const findUser = await prisma.user.findFirst({
where: {
email: email,
+6 -4
View File
@@ -3,7 +3,7 @@ import type { NextApiRequest, NextApiResponse } from "next";
import bcrypt from "bcrypt";
interface Data {
message: string | object;
response: string | object;
}
interface User {
@@ -19,7 +19,9 @@ export default async function Index(
const body: User = req.body;
if (!body.email || !body.password || !body.name)
return res.status(400).json({ message: "Please fill out all the fields." });
return res
.status(400)
.json({ response: "Please fill out all the fields." });
const checkIfUserExists = await prisma.user.findFirst({
where: {
@@ -40,8 +42,8 @@ export default async function Index(
},
});
res.status(201).json({ message: "User successfully created." });
res.status(201).json({ response: "User successfully created." });
} else if (checkIfUserExists) {
res.status(400).json({ message: "User already exists." });
res.status(400).json({ response: "User already exists." });
}
}