aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/routes/admin.dashboard.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/app/routes/admin.dashboard.tsx')
-rw-r--r--frontend/app/routes/admin.dashboard.tsx14
1 files changed, 6 insertions, 8 deletions
diff --git a/frontend/app/routes/admin.dashboard.tsx b/frontend/app/routes/admin.dashboard.tsx
index ce3e910..f91406f 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 { Form, Link } from "@remix-run/react";
+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;
}
@@ -26,6 +21,9 @@ export default function AdminDashboard() {
<p>
<Link to="/admin/games">Games</Link>
</p>
+ <Form method="post" action="/logout">
+ <button type="submit">Logout</button>
+ </Form>
</div>
);
}