2
0

fix(results): 🔒️ Improve delete security checks

This commit is contained in:
Baptiste Arnaud
2022-06-18 09:41:23 +02:00
parent 4e6217597c
commit 9352587298
6 changed files with 25 additions and 24 deletions

View File

@ -4,7 +4,6 @@ import { SubmissionsTable } from 'components/results/SubmissionsTable'
import React, { useCallback, useMemo, useState } from 'react'
import {
convertResultsToTableData,
deleteAllResults,
deleteResults,
getAllResults,
useResults,
@ -70,10 +69,11 @@ export const SubmissionsContent = ({
const selectedIds = (results ?? [])
.filter((_, idx) => selectedIndices.includes(idx))
.map((result) => result.id)
const { error } =
totalSelected === totalResults
? await deleteAllResults(typebotId)
: await deleteResults(typebotId, selectedIds)
const { error } = await deleteResults(
workspaceId,
typebotId,
totalSelected === totalResults ? [] : selectedIds
)
if (error) showToast({ description: error.message, title: error.name })
else {
mutate(