diff --git a/client/components/RequireAccess.tsx b/client/components/RequireAccess.tsx index a170620a..e22a2412 100644 --- a/client/components/RequireAccess.tsx +++ b/client/components/RequireAccess.tsx @@ -1,5 +1,8 @@ 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< @@ -15,7 +18,6 @@ export default function RequireAccess({ children, }: RequireAccessProps) { const { user, profile, roles } = useAuth(); - const location = useLocation(); const realmOk = !allowedRealms || allowedRealms.includes((profile as any)?.user_type); @@ -24,14 +26,41 @@ export default function RequireAccess({ (Array.isArray(roles) && roles.some((r) => allowedRoles.includes(r.toLowerCase()))); - if (!user) + if (!user) { return ( - + +
+
+ + + Access + Access denied + Sign in required to view this page. + + +
+
+
); - if (!realmOk || !rolesOk) return ; + } + + if (!realmOk || !rolesOk) { + return ( + +
+
+ + + Access + Access denied + You don’t have the required realm or role for this area. + + +
+
+
+ ); + } return children; }