mirror of
https://github.com/Since-3/Kuma.git
synced 2026-10-12 20:41:16 +00:00
new checking workflow auf registering a user
This commit is contained in:
parent
0e312fe29b
commit
eb928e3d80
1 changed files with 8 additions and 9 deletions
|
|
@ -23,6 +23,14 @@ export async function POST(request: Request) {
|
|||
);
|
||||
}
|
||||
|
||||
const existingUser = await prisma.user.findUnique({
|
||||
where: { email },
|
||||
});
|
||||
|
||||
if (existingUser) {
|
||||
return NextResponse.json({ error: "Dieser Nutzer existiert bereits." }, { status: 409 });
|
||||
}
|
||||
|
||||
const supabase = await createClient();
|
||||
|
||||
const { data, error } = await supabase.auth.signUp({
|
||||
|
|
@ -47,15 +55,6 @@ export async function POST(request: Request) {
|
|||
return NextResponse.json({ error: "User konnte nicht erstellt werden" }, { status: 500 });
|
||||
}
|
||||
|
||||
// Check if User exists in the DB
|
||||
const existingUser = await prisma.user.findUnique({
|
||||
where: { email },
|
||||
});
|
||||
|
||||
if (existingUser) {
|
||||
return NextResponse.json({ user: existingUser }, { status: 200 });
|
||||
}
|
||||
|
||||
const newUser = await prisma.user.create({
|
||||
data: {
|
||||
id: supabaseUser.id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue