Add auth checks for events calendar
This commit is contained in:
parent
7eefe190f5
commit
33ede3ba5e
@ -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;",
|
||||
|
Loading…
x
Reference in New Issue
Block a user