harden report references in boards
This commit is contained in:
1 parent
a4a0167515
commit
7bdc2f215e
8 files changed
+346
-10
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { z } from 'zod';
|
||||
import { hasValidBoardReports } from '@/permissions';
|
||||
import { parseRequest } from '@/lib/request';
|
||||
import { json, unauthorized } from '@/lib/response';
|
||||
import { badRequest, json, unauthorized } from '@/lib/response';
|
||||
import { createBoard, getBoard, updateBoard } from '@/queries/prisma';
|
||||
|
||||
export async function GET(request: Request) {
|
||||
@@ -45,6 +46,10 @@ export async function POST(request: Request) {
|
||||
parameters: body.parameters ?? {},
|
||||
};
|
||||
|
||||
if (!(await hasValidBoardReports(existing?.type ?? 'dashboard', data.parameters))) {
|
||||
return badRequest({ message: 'Board contains invalid saved reports.' });
|
||||
}
|
||||
|
||||
if (existing) {
|
||||
const result = await updateBoard(userId, data);
|
||||
|
||||
|
||||
Reference in new issue
Block a user