diff --git a/app/routes/events-team.tsx b/app/routes/events-team.tsx index fbafdfb..69f8b93 100644 --- a/app/routes/events-team.tsx +++ b/app/routes/events-team.tsx @@ -26,6 +26,11 @@ import { useLoaderData } from "@remix-run/react"; import { type ReactNode, useState } from "react"; export async function loader({ context }: { context: RequestContext }) { + if (!context.data.current_user) + throw new Response(null, { + status: 401, + }); + const now = new Date(); const monthEventList = await context.env.D1.prepare( "SELECT approved, created_by, day, id, month, pending, type, year FROM events WHERE month = ? AND year = ?;", @@ -40,7 +45,7 @@ export async function loader({ context }: { context: RequestContext }) { return { can_approve: Boolean( - [1 << 4, 1 << 12].find((p) => context.data.user.permissions & p), + [1 << 4, 1 << 12].find((p) => context.data.current_user.permissions & p), ), events: monthEventList.results, };