stream day 2

This commit is contained in:
Zoe
2023-01-03 15:11:36 -06:00
parent 0bece5d0fc
commit 47afcbb8ec
23 changed files with 605 additions and 37 deletions

View File

@@ -13,6 +13,26 @@ export default defineEventHandler(async (event) => {
}
}
const preExistingUser = await prisma.user.findFirst({
where: {
OR: [
{
username: body.username
},
{
email: body.email
}
]
}
})
if (preExistingUser) {
event.node.res.statusCode = 409;
return {
message: `User with username ${body.username} or email ${body.email} already exists`
}
}
const passwordhash = await bcryptjs.hash(body.password, 10)
const user = await prisma.user.create({