added footer links, added email alias check
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user