From cce71c9093d5e611681a47f25fa2d18622f2cbce Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:49:12 -0400 Subject: [PATCH] Create login check middleware for all appeals api routes --- functions/api/appeals/_middleware.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 functions/api/appeals/_middleware.ts diff --git a/functions/api/appeals/_middleware.ts b/functions/api/appeals/_middleware.ts new file mode 100644 index 0000000..145e453 --- /dev/null +++ b/functions/api/appeals/_middleware.ts @@ -0,0 +1,12 @@ +export async function onRequest(context: RequestContext) { + if (!context.data.current_user) + return new Response('{"error":"Not logged in"}', { + headers: { + "content-type": "application/json", + }, + status: 401, + }); + + + return await context.next(); +}