From 33ede3ba5e725cb5309194fb1c5c3de6f110c6ae Mon Sep 17 00:00:00 2001 From: Regalijan Date: Wed, 18 Sep 2024 13:46:26 -0400 Subject: [PATCH] Add auth checks for events calendar --- app/routes/events-calendar.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/routes/events-calendar.tsx b/app/routes/events-calendar.tsx index ad02fd9..3213e09 100644 --- a/app/routes/events-calendar.tsx +++ b/app/routes/events-calendar.tsx @@ -10,6 +10,20 @@ export const links: LinksFunction = () => { }; export async function loader({ context }: { context: RequestContext }) { + if (!context.data.current_user) + throw new Response(null, { + status: 401, + }); + + if ( + [1 << 3, 1 << 4, 1 << 12].find( + (p) => context.data.current_user.permissions & p, + ) + ) + throw new Response(null, { + status: 403, + }); + const now = new Date(); const eventsData = await context.env.D1.prepare( "SELECT answer, approved, created_by, day, details, id, month, pending, performed_at, reached_minimum_player_count, type, year FROM events WHERE month = ? AND year = ? ORDER BY day;",