Add auth checks for events calendar

This commit is contained in:
Regalijan 2024-09-18 13:46:26 -04:00
parent 7eefe190f5
commit 33ede3ba5e
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -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;",