From 45e05d78c7e698de2446d04a671435db7e1a457a Mon Sep 17 00:00:00 2001 From: regalijan <r@regalijan.com> Date: Thu, 19 Oct 2023 16:50:17 -0400 Subject: [PATCH] Handle ip auth for report recall endpoint --- functions/api/reports/recall.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/functions/api/reports/recall.ts b/functions/api/reports/recall.ts index 420308a..9dbe166 100644 --- a/functions/api/reports/recall.ts +++ b/functions/api/reports/recall.ts @@ -11,7 +11,11 @@ export async function onRequestPost(context: RequestContext) { const reportUserId = await context.env.DATA.get(`reportprocessing_${id}`); - if (!reportUserId || context.data.current_user?.id !== reportUserId) + if ( + !reportUserId || + (context.data.current_user?.id !== reportUserId && + context.request.headers.get("CF-Connecting-IP") !== reportUserId) + ) return new Response('{"error":"No processing report with that ID found"}', { headers: { "content-type": "application/json",