Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const accessIfAuthenticated = Component => props => {
let AugmentedComponent;
const { state: { firebase } } = useContext(SiteContext);
const { initialising, user } = useAuthState(firebase.auth);
const userLoggedIn = !initialising && (user !== null);
if(initialising) {
AugmentedComponent = withCurUserInfo()({});
}
else if(userLoggedIn) {
AugmentedComponent = withCurUserInfo(Component)(props);
}
else {
console.warn("Whoops! You're not logged in. If this is an error or a bug, please email alex@equithon.org.")
AugmentedComponent = withCurUserInfo()({ redirect: true });
}
return AugmentedComponent;
};
export const App: React.FunctionComponent = props => {
const { initialising, user } = useAuthState(firebase.auth());
return (
function App() {
const { initialising, user } = useAuthState(firebase.auth());
if (initialising) {
return (
<div style="{{">
</div>
);
}