Gate setup and admin navigation
All checks were successful
Build / build (push) Successful in 9m18s
Template Compliance / compliance (push) Successful in 6s
Release Dry Run / release-dry-run (push) Successful in 1m28s

This commit is contained in:
MrSphay
2026-05-15 17:32:26 +02:00
parent 4dbd595061
commit 035a255125
11 changed files with 98 additions and 30 deletions

View File

@@ -3,21 +3,10 @@ import { hash } from "bcryptjs";
import { prisma } from "@/lib/prisma";
import { SYSTEM_PERMISSIONS } from "@/lib/access";
import { setSession } from "@/lib/session";
import { hasAdminUser } from "@/lib/setup";
export const dynamic = "force-dynamic";
async function hasAdmin() {
try {
const admin = await prisma.userRole.findFirst({
where: { role: { name: "admin" } },
select: { userId: true }
});
return Boolean(admin);
} catch {
return false;
}
}
async function createFirstAdmin(formData: FormData) {
"use server";
@@ -95,7 +84,7 @@ async function createFirstAdmin(formData: FormData) {
}
export default async function SetupPage() {
if (await hasAdmin()) {
if (await hasAdminUser()) {
redirect("/login");
}