How to use the @axa-fr/react-oidc-core.withRouter function in @axa-fr/react-oidc-core

To help you get started, we’ve selected a few @axa-fr/react-oidc-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AxaGuilDEv / react-oidc / packages / context / src / Context / AuthenticationConsumers.js View on Github external
authenticateUserInternal(usermanager, location)();
    }
    return () => {
      oidcLog.info('Protected component unmounted');
    };
  }, [location, isEnabled, authenticateUserInternal, getUserManagerInternal]);
  return { oidcUser, authenticating, isEnabled };
};

// for usage
export const useReactOidc = () => {
  const { isEnabled, login, logout, oidcUser } = useContext(AuthenticationContext);
  return { isEnabled, login, logout, oidcUser };
};

const OidcSecure = withRouter(({ children, location }) => {
  const { oidcUser, authenticating, isEnabled } = useOidcSecure(
    authenticateUser,
    getUserManager,
    location
  );
  const requiredAuth = useMemo(() => isRequireAuthentication(oidcUser, false) && isEnabled, [
    isEnabled,
    oidcUser,
  ]);
  const AuthenticatingComponent = authenticating || Authenticating;
  return requiredAuth ?  : <div>{children}</div>;
});

export default OidcSecure;

// For non-regression
github AxaGuilDEv / react-oidc / packages / context / src / Context / AuthenticationContext.container.js View on Github external
]),
      }}
    &gt;
      
        {children}
      
    
  );
};

const AuthenticationProvider = withRouter(withServices(AuthenticationProviderInt, { Callback }));
AuthenticationProvider.propTypes = propTypes;
AuthenticationProvider.defaultProps = defaultProps;
AuthenticationProvider.displayName = 'AuthenticationProvider';

export default AuthenticationProvider;
github AxaGuilDEv / react-oidc / packages / context / src / Callback / Callback.container.js View on Github external
getUserManager: getUserManagerInternal,
  oidcLog: oidcLogInternal,
  callbackComponentOverride: CallbackComponentOverride,
}) =&gt; {
  const onSuccess = onRedirectSuccess(history, oidcLogInternal);
  const onError = onRedirectError(history, oidcLogInternal);

  useEffect(() =&gt; {
    getUserManagerInternal()
      .signinRedirectCallback()
      .then(onSuccess, onError);
  }, [getUserManagerInternal, onError, onSuccess]);
  return CallbackComponentOverride ?  : ;
};

const CallbackContainer = withRouter(
  withServices(CallbackContainerCore, {
    getUserManager,
    oidcLog,
  })
);

export default React.memo(CallbackContainer);
github AxaGuilDEv / react-oidc / packages / context / src / Context / AuthenticationConsumers.js View on Github external
export const withOidcSecure = WrappedComponent =>
  withRouter(
    withServices(withOidcSecurewithRouter(WrappedComponent), {
      authenticateUser,
      getUserManager,
    })
  );