aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/routes/admin.dashboard.tsx
blob: d5f3809ca00a9c98a38080eea4cae2d87c0e2c79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
import { Link } from "@remix-run/react";
import { isAuthenticated } from "../.server/auth";

export const meta: MetaFunction = () => {
  return [{ title: "[Admin] Dashboard | iOSDC 2024 Albatross.swift" }];
};

export async function loader({ request }: LoaderFunctionArgs) {
  const { user } = await isAuthenticated(request, {
    failureRedirect: "/login",
  });
  if (!user.is_admin) {
    throw new Error("Unauthorized");
  }
  return null;
}

export default function AdminDashboard() {
  return (
    <div>
      <h1>[Admin] Dashboard</h1>
      <p>
        <Link to="/admin/users">Users</Link>
      </p>
    </div>
  );
}