14 lines
340 B
TypeScript
14 lines
340 B
TypeScript
|
|
import { useScopes } from '../auth/useScopes';
|
||
|
|
|
||
|
|
interface Props {
|
||
|
|
scope: string;
|
||
|
|
children: React.ReactNode;
|
||
|
|
fallback?: React.ReactNode;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function RequireScope({ scope, children, fallback }: Props) {
|
||
|
|
const scopes = useScopes();
|
||
|
|
if (!scopes.has(scope)) return fallback ? <>{fallback}</> : null;
|
||
|
|
return <>{children}</>;
|
||
|
|
}
|