diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-08-01 22:43:27 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-08-01 23:12:07 +0900 |
| commit | 3d566086003efd952cd1535ee9d971dab5d58a15 (patch) | |
| tree | 2576c94ab3fba3820bd7ef765ef22a035581d9ba /frontend/app/routes/admin.games.tsx | |
| parent | 13e9a10c1964bc40c698efa7bc8e47acc5cb25b4 (diff) | |
| download | phperkaigi-2025-albatross-3d566086003efd952cd1535ee9d971dab5d58a15.tar.gz phperkaigi-2025-albatross-3d566086003efd952cd1535ee9d971dab5d58a15.tar.zst phperkaigi-2025-albatross-3d566086003efd952cd1535ee9d971dab5d58a15.zip | |
refactor(frontend): simplify login check
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 }; } |
