Files
WatchLink/src/lib/setup.ts

21 lines
433 B
TypeScript
Raw Normal View History

2026-05-15 17:32:26 +02:00
import { redirect } from "next/navigation";
import { prisma } from "./prisma";
export async function hasAdminUser() {
try {
const admin = await prisma.userRole.findFirst({
where: { role: { name: "admin" } },
select: { userId: true }
});
return Boolean(admin);
} catch {
return false;
}
}
export async function requireInitialSetup() {
if (!(await hasAdminUser())) {
redirect("/setup");
}
}