Harden form auth and submission handling
This commit is contained in:
+2
-10
@@ -11,9 +11,9 @@ import {
|
||||
} from "@/components/ui/table";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Plus } from "lucide-react";
|
||||
import { redirect } from "next/navigation";
|
||||
import { DeleteFormButton } from "@/components/delete-buttons";
|
||||
import { AdminShellServer } from "@/components/admin-shell-server";
|
||||
import { createDefaultForm } from "./actions";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -32,15 +32,7 @@ export default async function AdminFormsPage() {
|
||||
Manage your custom forms and view submissions.
|
||||
</p>
|
||||
</div>
|
||||
<form action={async () => {
|
||||
"use server";
|
||||
const { forms } = await import("@/db/schema");
|
||||
const [newForm] = await db.insert(forms).values({
|
||||
title: "New Form",
|
||||
description: "",
|
||||
}).returning();
|
||||
redirect(`/admin/form/${newForm.id}`);
|
||||
}}>
|
||||
<form action={createDefaultForm}>
|
||||
<Button type="submit">
|
||||
<Plus className="mr-2 h-4 w-4" />
|
||||
Create Form
|
||||
|
||||
Reference in New Issue
Block a user