diff options
Diffstat (limited to 'frontend/app/routes/admin.games.tsx')
| -rw-r--r-- | frontend/app/routes/admin.games.tsx | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/frontend/app/routes/admin.games.tsx b/frontend/app/routes/admin.games.tsx index af3554e..23e45c5 100644 --- a/frontend/app/routes/admin.games.tsx +++ b/frontend/app/routes/admin.games.tsx @@ -1,19 +1,14 @@ import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node"; import { Link, useLoaderData } from "@remix-run/react"; import { adminApiGetGames } from "../.server/api/client"; -import { isAuthenticated } from "../.server/auth"; +import { ensureAdminUserLoggedIn } from "../.server/auth"; export const meta: MetaFunction = () => { return [{ title: "[Admin] Games | iOSDC Japan 2024 Albatross.swift" }]; }; export async function loader({ request }: LoaderFunctionArgs) { - const { user, token } = await isAuthenticated(request, { - failureRedirect: "/login", - }); - if (!user.is_admin) { - throw new Error("Unauthorized"); - } + const { token } = await ensureAdminUserLoggedIn(request); const { games } = await adminApiGetGames(token); return { games }; } |
