Fix period editing and harden app with Next.js security upgrade
This commit is contained in:
@@ -6,12 +6,13 @@ import prisma from "@/lib/prisma";
|
||||
import { getCurrentViewer } from "@/lib/session";
|
||||
|
||||
type Context = {
|
||||
params: {
|
||||
params: Promise<{
|
||||
id: string;
|
||||
};
|
||||
}>;
|
||||
};
|
||||
|
||||
export async function POST(_: Request, { params }: Context) {
|
||||
const { id } = await params;
|
||||
const viewer = await getCurrentViewer();
|
||||
|
||||
if (!viewer) {
|
||||
@@ -23,7 +24,7 @@ export async function POST(_: Request, { params }: Context) {
|
||||
}
|
||||
|
||||
const expense = await prisma.expense.findUnique({
|
||||
where: { id: params.id }
|
||||
where: { id }
|
||||
});
|
||||
|
||||
if (!expense) {
|
||||
@@ -35,7 +36,7 @@ export async function POST(_: Request, { params }: Context) {
|
||||
}
|
||||
|
||||
const updatedExpense = await prisma.expense.update({
|
||||
where: { id: params.id },
|
||||
where: { id },
|
||||
data: {
|
||||
paidAt: expense.paidAt ?? new Date()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user