diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-08-01 23:34:59 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-08-01 23:34:59 +0900 |
| commit | db06c9332776b41b3fef537f9e6d76d38f0463b3 (patch) | |
| tree | b25c8226efa42be3e631cdf2f047c13c1b807889 /frontend/app/routes/admin.games_.$gameId.tsx | |
| parent | 6b600ca0ca50c9322a95858bd7d4b6813a7ba2d5 (diff) | |
| parent | ca4e86c99a935c41b319efea43365221569c7d62 (diff) | |
| download | phperkaigi-2025-albatross-db06c9332776b41b3fef537f9e6d76d38f0463b3.tar.gz phperkaigi-2025-albatross-db06c9332776b41b3fef537f9e6d76d38f0463b3.tar.zst phperkaigi-2025-albatross-db06c9332776b41b3fef537f9e6d76d38f0463b3.zip | |
Merge branch 'feat/auth'
Diffstat (limited to 'frontend/app/routes/admin.games_.$gameId.tsx')
| -rw-r--r-- | frontend/app/routes/admin.games_.$gameId.tsx | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/frontend/app/routes/admin.games_.$gameId.tsx b/frontend/app/routes/admin.games_.$gameId.tsx index 34860ab..0d2cac6 100644 --- a/frontend/app/routes/admin.games_.$gameId.tsx +++ b/frontend/app/routes/admin.games_.$gameId.tsx @@ -5,7 +5,7 @@ import type { } from "@remix-run/node"; import { Form, useLoaderData } from "@remix-run/react"; import { adminApiGetGame, adminApiPutGame } from "../.server/api/client"; -import { isAuthenticated } from "../.server/auth"; +import { ensureAdminUserLoggedIn } from "../.server/auth"; export const meta: MetaFunction<typeof loader> = ({ data }) => { return [ @@ -18,24 +18,14 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => { }; export async function loader({ request, params }: LoaderFunctionArgs) { - const { user, token } = await isAuthenticated(request, { - failureRedirect: "/login", - }); - if (!user.is_admin) { - throw new Error("Unauthorized"); - } + const { token } = await ensureAdminUserLoggedIn(request); const { gameId } = params; const { game } = await adminApiGetGame(token, Number(gameId)); return { game }; } export async function action({ request, params }: ActionFunctionArgs) { - const { user, token } = await isAuthenticated(request, { - failureRedirect: "/login", - }); - if (!user.is_admin) { - throw new Error("Unauthorized"); - } + const { token } = await ensureAdminUserLoggedIn(request); const { gameId } = params; const formData = await request.formData(); |
