Add auth checks to et pages

This commit is contained in:
2024-02-26 14:05:43 -05:00
parent b34ca64200
commit 18e63c22dd
3 changed files with 44 additions and 0 deletions

View File

@ -11,8 +11,29 @@ import {
} from "@chakra-ui/react";
import { useEffect, useState } from "react";
import Success from "../../components/Success.js";
import { useLoaderData } from "@remix-run/react";
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,
});
return null;
}
export default function () {
useLoaderData<typeof loader>();
const toast = useToast();
const currentDate = new Date();
const currentMonth = currentDate.getUTCMonth() + 1;