import { NextResponse } from "next/server";
import { requireAdminSession } from "@/lib/admin/auth";
import { saveSmtpSettings } from "@/lib/admin/store";

export async function POST(request: Request) {
  if (!await requireAdminSession()) return NextResponse.json({ message: "Nicht autorisiert." }, { status: 401 });
  await saveSmtpSettings(await request.formData());
  return new NextResponse(null, { status: 303, headers: { Location: "/admin/smtp?saved=1" } });
}
