minor error handling

This commit is contained in:
Daniel
2023-07-18 12:44:37 -04:00
parent 010d8d12ff
commit 2bd9a97d2f
2 changed files with 34 additions and 17 deletions
+20
View File
@@ -20,6 +20,26 @@ export default async function updateUser(
status: 400,
};
const userIsTaken = await prisma.user.findFirst({
where: {
id: { not: sessionUser.id },
OR: [
{
username: user.username.toLowerCase(),
},
{
email: user.email.toLowerCase(),
},
],
},
});
if (userIsTaken)
return {
response: "Username/Email is taken.",
status: 400,
};
// Avatar Settings
const profilePic = user.profilePic;