feat: implement discord-based admin authentication for the form management page and add skill documentation

This commit is contained in:
2026-06-30 22:35:11 +07:00 Unverified
parent 2e3983e38c
commit 19fde79fd0
2 changed files with 12 additions and 0 deletions
+12
View File
@@ -14,10 +14,22 @@ import { Badge } from "@/components/ui/badge";
import { Plus, Trash2 } from "lucide-react";
import { redirect } from "next/navigation";
import { deleteForm } from "@/app/actions/form";
import { getServerSession } from "next-auth";
import { authOptions } from "@/app/api/auth/[...nextauth]/route";
export const dynamic = "force-dynamic";
export default async function AdminFormsPage() {
const session = await getServerSession(authOptions);
const adminIds = (process.env.ADMIN_DISCORD_IDS ?? "")
.split(",")
.map((s) => s.trim())
.filter(Boolean);
const discordId = (session?.user as any)?.discordId;
if (!discordId || !adminIds.includes(discordId)) {
redirect("/");
}
const formsList = await db.query.forms.findMany({
orderBy: (f, { desc }) => [desc(f.createdAt)],
});
View File