diff --git a/src/pages/(admin)/UserCreator.tsx b/src/pages/(admin)/UserCreator.tsx index 12415726..03fc35e6 100644 --- a/src/pages/(admin)/UserCreator.tsx +++ b/src/pages/(admin)/UserCreator.tsx @@ -141,7 +141,11 @@ export default function UserCreator({user, users, permissions, onFinish}: Props) setType("student"); setPosition(undefined); }) - .catch(() => toast.error("Something went wrong! Please try again later!")) + .catch((error) => { + const data = error?.response?.data; + if (!!data?.message) return toast.error(data.message); + toast.error("Something went wrong! Please try again later!"); + }) .finally(() => setIsLoading(false)); }; diff --git a/src/pages/api/make_user.ts b/src/pages/api/make_user.ts index 31b0e69d..b8128015 100644 --- a/src/pages/api/make_user.ts +++ b/src/pages/api/make_user.ts @@ -218,6 +218,8 @@ async function post(req: NextApiRequest, res: NextApiResponse) { return res.status(200).json({ok: true}); }) .catch((error) => { + if (error.code.includes("email-already-in-use")) return res.status(403).json({error, message: "E-mail is already in the platform."}); + console.log(`Failing - ${email}`); console.log(error); return res.status(401).json({error});