blob: be274eb9b69f7484c5e6d53ae2d0f3771688a6be (
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 "../services/auth.server";
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>
);
}
|