import * as React from 'react' ; import { AuthHandlers } from "../../../web/js/apps/repository/auth_handler/AuthHandler" ; import { useUserInfoContext } from "../../../web/js/apps/repository/auth_handler/UserInfoProvider" ; interface IProps { readonly children : React . ReactElement ; } export const AuthRequired = React . memo ( function AuthRequired ( props ) { const userInfoContext = useUserInfoContext ( ) ; if ( ! userInfoContext ) { return ( < div className = 'AuthRequiredNoUserInfoContext' > < /div>); } if ( ! userInfoContext . userInfo ) { console . warn ( "No userInfo: forcing authentication" ) ; const authHandler = AuthHandlers . get ( ) ; authHandler . authenticate ( document . location . href ) ; return ( < div className = 'AuthRequiredNoUserInfo' > < /div>); } return props . children ; } ) ; AuthRequired . displayName = 'AuthRequired' ;