UNPKG

@keycloakify/keycloak-admin-ui

Version:
24 lines 882 B
import { jsx as _jsx } from "react/jsx-runtime"; import { useMatches } from "react-router-dom"; import { ForbiddenSection } from "../ForbiddenSection"; import { useAccess } from "../context/access/Access"; function hasProp(data, prop) { return prop in data; } export const AuthWall = ({ children }) => { const matches = useMatches(); const { hasAccess } = useAccess(); const permissionNeeded = matches.flatMap(({ handle }) => { if (typeof handle !== "object" || handle === null || !hasProp(handle, "access")) { return []; } if (Array.isArray(handle.access)) { return handle.access; } return [handle.access]; }); return hasAccess(...permissionNeeded) ? (children) : (_jsx(ForbiddenSection, { permissionNeeded: permissionNeeded })); }; //# sourceMappingURL=AuthWall.js.map