From 09d37041bceeaf83f0556f331127d2a3a9c17008 Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:50:33 -0400 Subject: [PATCH] Add basic events api middleware --- functions/api/events-team/events/_middleware.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 functions/api/events-team/events/_middleware.ts diff --git a/functions/api/events-team/events/_middleware.ts b/functions/api/events-team/events/_middleware.ts new file mode 100644 index 0000000..79e2ab5 --- /dev/null +++ b/functions/api/events-team/events/_middleware.ts @@ -0,0 +1,15 @@ +export async function onRequest(context: RequestContext) { + if ( + ![1 << 3, 1 << 4, 1 << 12].find( + (int) => context.data.current_user?.permissions & int, + ) + ) + return new Response('{"error":"Forbidden"}', { + headers: { + "content-type": "application/json", + }, + status: 401, + }); + + return await context.next(); +}