File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,12 +4,15 @@ import { useAuth } from "react-oidc-context";
44/**
55 * @author Aloento
66 * @since 1.0.0
7- * @version 0.1 .0
7+ * @version 0.2 .0
88 */
9- export function Authorized ( { children } : { children : ReactNode } ) : ReactNode {
9+ export function Authorized ( { children, role } : { children : ReactNode , role ?: string } ) : ReactNode {
1010 const auth = useAuth ( ) ;
1111
1212 if ( auth . isAuthenticated || process . env . NODE_ENV === "development" ) {
13+ if ( role && ! ( ( auth . user ?. profile as any ) ?. groups as string [ ] ) ?. includes ( role ) ) {
14+ return null ;
15+ }
1316 return children ;
1417 }
1518
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { Authorized } from "../Auth/With";
55/**
66 * @author Aloento
77 * @since 1.0.0
8- * @version 0.1 .0
8+ * @version 0.2 .0
99 */
1010export function MobileMenu ( ) {
1111 const auth = useAuth ( ) ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { useAuth } from "react-oidc-context";
44/**
55 * @author Aloento
66 * @since 1.0.0
7- * @version 0.1 .0
7+ * @version 0.2 .0
88 */
99export function ProfileMenu ( ) {
1010 const auth = useAuth ( ) ;
You can’t perform that action at this time.
0 commit comments