kilogramm/frontend/src/features/auth/withAuth/withAuth.tsx

18 lines
417 B
TypeScript

import { cn } from '@bem-react/classname';
import { useKeycloakAuth } from '../keycloak';
import React from 'react';
import './withAuth.scss';
const name = cn('NotAuthenticated');
export function withAuth(Cmp: React.FC) {
return () => {
const { authenticated } = useKeycloakAuth();
return authenticated ? <Cmp /> : <div className={name()}>
Not authenticated
</div>
}
}