Added Account Dublicate fucntion, improved default sorts

This commit is contained in:
PxlLoewe
2025-12-26 01:23:32 +01:00
parent 51ef9cd90c
commit 17208eded9
18 changed files with 486 additions and 139 deletions

View File

@@ -0,0 +1,33 @@
import { NextResponse } from "next/server";
import { prisma } from "@repo/db";
export async function GET(req: Request) {
const { searchParams } = new URL(req.url);
const publicId = searchParams.get("publicId")?.trim();
const email = searchParams.get("email")?.trim()?.toLowerCase();
if (!publicId && !email) {
return NextResponse.json({ error: "Missing query" }, { status: 400 });
}
try {
const user = await prisma.user.findFirst({
where: {
OR: [publicId ? { publicId } : undefined, email ? { email } : undefined].filter(
Boolean,
) as any,
},
select: {
id: true,
publicId: true,
firstname: true,
lastname: true,
isBanned: true,
},
});
if (!user) return NextResponse.json({ user: null }, { status: 200 });
return NextResponse.json({ user }, { status: 200 });
} catch (e) {
return NextResponse.json({ error: "Server error" }, { status: 500 });
}
}