From 3d566086003efd952cd1535ee9d971dab5d58a15 Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Thu, 1 Aug 2024 22:43:27 +0900
Subject: refactor(frontend): simplify login check

---
 frontend/app/routes/admin.dashboard.tsx | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

(limited to 'frontend/app/routes/admin.dashboard.tsx')

diff --git a/frontend/app/routes/admin.dashboard.tsx b/frontend/app/routes/admin.dashboard.tsx
index ce3e910..4eb90b5 100644
--- a/frontend/app/routes/admin.dashboard.tsx
+++ b/frontend/app/routes/admin.dashboard.tsx
@@ -1,18 +1,13 @@
 import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
 import { Link } from "@remix-run/react";
-import { isAuthenticated } from "../.server/auth";
+import { ensureAdminUserLoggedIn } from "../.server/auth";
 
 export const meta: MetaFunction = () => {
 	return [{ title: "[Admin] Dashboard | iOSDC Japan 2024 Albatross.swift" }];
 };
 
 export async function loader({ request }: LoaderFunctionArgs) {
-	const { user } = await isAuthenticated(request, {
-		failureRedirect: "/login",
-	});
-	if (!user.is_admin) {
-		throw new Error("Unauthorized");
-	}
+	await ensureAdminUserLoggedIn(request);
 	return null;
 }
 
-- 
cgit v1.2.3-70-g09d2

