added footer links, added email alias check

This commit is contained in:
PxlLoewe
2025-06-06 11:54:03 -07:00
parent 587884dfd9
commit b1262c4278
11 changed files with 141 additions and 97 deletions

View File

@@ -2,10 +2,7 @@
import { prisma, Prisma } from "@repo/db";
import bcrypt from "bcryptjs";
export const register = async ({
password,
...user
}: Omit<Prisma.UserCreateInput, "publicId">) => {
export const register = async ({ password, ...user }: Omit<Prisma.UserCreateInput, "publicId">) => {
const hashedPassword = await bcrypt.hash(password, 12);
const lastUserPublicId = await prisma.user.findFirst({
select: {
@@ -21,6 +18,18 @@ export const register = async ({
varPublicId = `VAR${(lastUserInt + 1).toString().padStart(4, "0")}`;
}
const existingUser = await prisma.user.findFirst({
where: {
email: user.email,
},
select: {
id: true,
},
});
if (existingUser) {
throw new Error("Ein Nutzer mit dieser E-Mail-Adresse existiert bereits.");
}
const newUser = prisma.user.create({
data: {
...user,