Initial commit

This commit is contained in:
JetSprow
2026-04-29 05:12:39 +10:00
commit 27dbca9cbf
379 changed files with 43486 additions and 0 deletions

18
src/lib/require-auth.ts Normal file
View File

@@ -0,0 +1,18 @@
import { getServerSession } from "next-auth";
import { authOptions } from "./auth";
export async function requireAdmin() {
const session = await getServerSession(authOptions);
if (!session || session.user.role !== "ADMIN") {
throw new Error("无权限");
}
return session;
}
export async function requireAuth() {
const session = await getServerSession(authOptions);
if (!session) {
throw new Error("未登录");
}
return session;
}