aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/routes/dashboard.tsx
blob: 535642c69a8b84d3576c069ec3665feaa3b95791 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import type { LoaderFunctionArgs } from "@remix-run/node";
import { isAuthenticated } from "../.server/auth";
import { useLoaderData } from "@remix-run/react";

export async function loader({ request }: LoaderFunctionArgs) {
  return await isAuthenticated(request, {
    failureRedirect: "/login",
  });
}

export default function Dashboard() {
  const user = useLoaderData<typeof loader>()!;

  return (
    <div>
      <h1>
        #{user.userId} {user.displayUsername} (@{user.username})
      </h1>
      {user.isAdmin && <p>Admin</p>}
    </div>
  );
}