Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
]),
}}
>
{children}
);
};
const AuthenticationProvider = withRouter(withServices(AuthenticationProviderInt, { Callback }));
AuthenticationProvider.propTypes = propTypes;
AuthenticationProvider.defaultProps = defaultProps;
AuthenticationProvider.displayName = 'AuthenticationProvider';
export default AuthenticationProvider;
getUserManager: getUserManagerInternal,
oidcLog: oidcLogInternal,
callbackComponentOverride: CallbackComponentOverride,
}) => {
const onSuccess = onRedirectSuccess(history, oidcLogInternal);
const onError = onRedirectError(history, oidcLogInternal);
useEffect(() => {
getUserManagerInternal()
.signinRedirectCallback()
.then(onSuccess, onError);
}, [getUserManagerInternal, onError, onSuccess]);
return CallbackComponentOverride ? : ;
};
const CallbackContainer = withRouter(
withServices(CallbackContainerCore, {
getUserManager,
oidcLog,
})
);
export default React.memo(CallbackContainer);
export const withOidcSecure = WrappedComponent =>
withRouter(
withServices(withOidcSecurewithRouter(WrappedComponent), {
authenticateUser,
getUserManager,
})
);