AeThex-OS/temp-forge-extract/aethex-forge-main/client/components/RequireAccess.tsx
MrPiglr b3c308b2c8 Add functional marketplace modules, bottom nav bar, root terminal, arcade games
- ModuleManager: Central tracking for installed marketplace modules
- DataAnalyzerWidget: Real-time CPU/RAM/Battery/Storage widget (unlocked by Data Analyzer module)
- BottomNavBar: Navigation bar for Projects/Chat/Marketplace/Settings
- RootShell: Real root command execution utility
- TerminalActivity: Full root shell with neofetch, sysinfo, real Linux commands
- Terminal Pro module: Adds aliases (ll, la, h), command history
- ArcadeActivity + SnakeGame: Pixel Arcade module unlocks retro games
- fade_in/fade_out animations for smooth transitions
2026-02-18 22:03:50 -07:00

85 lines
2.4 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Navigate, useLocation } from "react-router-dom";
import { useAuth } from "@/contexts/AuthContext";
import Layout from "@/components/Layout";
import {
Card,
CardHeader,
CardTitle,
CardDescription,
} from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
interface RequireAccessProps {
allowedRealms?: Array<
"game_developer" | "client" | "community_member" | "customer" | "staff"
>;
allowedRoles?: string[];
children: React.ReactElement;
}
export default function RequireAccess({
allowedRealms,
allowedRoles,
children,
}: RequireAccessProps) {
const { user, profile, roles } = useAuth();
const realmOk =
!allowedRealms || allowedRealms.includes((profile as any)?.user_type);
const rolesOk =
!allowedRoles ||
(Array.isArray(roles) &&
roles.some((r) => allowedRoles.includes(r.toLowerCase())));
if (!user) {
return (
<Layout>
<div className="min-h-screen bg-aethex-gradient py-12">
<section className="container mx-auto max-w-3xl px-4">
<Card className="bg-card/60 border-border/40 backdrop-blur">
<CardHeader>
<Badge
variant="outline"
className="mb-2 border-aethex-400/50 text-aethex-300"
>
Access
</Badge>
<CardTitle>Access denied</CardTitle>
<CardDescription>
Sign in required to view this page.
</CardDescription>
</CardHeader>
</Card>
</section>
</div>
</Layout>
);
}
if (!realmOk || !rolesOk) {
return (
<Layout>
<div className="min-h-screen bg-aethex-gradient py-12">
<section className="container mx-auto max-w-3xl px-4">
<Card className="bg-card/60 border-border/40 backdrop-blur">
<CardHeader>
<Badge
variant="outline"
className="mb-2 border-aethex-400/50 text-aethex-300"
>
Access
</Badge>
<CardTitle>Access denied</CardTitle>
<CardDescription>
You dont have the required realm or role for this area.
</CardDescription>
</CardHeader>
</Card>
</section>
</div>
</Layout>
);
}
return children;
}