Skip to content

Commit

Permalink
add basic authentication redirect for managers page (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
mahmoudmoravej authored Nov 15, 2023
1 parent cc33d03 commit 9dec6bf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/routes/managers/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import {
IconButton,
Tooltip,
} from "@material-tailwind/react";
import { LoaderFunction, redirect } from "@remix-run/node";
import { useNavigate } from "@remix-run/react";
import { authenticator } from "~/services/auth.server";

const TABS = [
{
Expand All @@ -36,6 +38,13 @@ const TABS = [

const TABLE_HEAD = ["Member", "Function", "Status", "Employed", ""];

export let loader: LoaderFunction = async ({ request }) => {
//we should completely change the following appraoch
let isAllowed = await authenticator.isAuthenticated(request);
if (!isAllowed) return redirect("/login");
else return {};
};

export default function Managers() {
const { data, loading, error } = useManagersQuery();
const navigate = useNavigate();
Expand Down

0 comments on commit 9dec6bf

Please sign in to comment.