Skip to content

Commit

Permalink
feat: admin middleware and route
Browse files Browse the repository at this point in the history
  • Loading branch information
kyzsuukii committed Mar 31, 2024
1 parent a117548 commit c991270
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/routes/_admin.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createFileRoute, redirect } from "@tanstack/react-router";

export const Route = createFileRoute("/_admin")({
beforeLoad: async ({ context: { session, isAdmin } }) => {
if (session && !isAdmin) {
throw redirect({ to: "/" });
}
},
});
9 changes: 9 additions & 0 deletions src/routes/_admin/dashboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createFileRoute } from "@tanstack/react-router";

export const Route = createFileRoute("/_admin/dashboard")({
component: Dashboard,
});

function Dashboard() {
return <div className="my-12 container mx-auto">Dashboard</div>;
}

0 comments on commit c991270

Please sign in to comment.