The structure of a Lore application


This file provides a higher order component that you can use to block access to the application (or some part of it) if the user is not logged in.

When this component is mounted, the isAuthenticated() method will be invoked.

If it returns true, the component this wraps will be rendered, and the application will appear as if this decorator doesn't exist.

If it returns false, this component renders nothing, and the redirect() method will be invoked to redirect the user somewhere else. The default location is /login.

import PropTypes from 'prop-types';
import { AuthenticationGenerator } from 'lore-auth';
import auth from '../utils/auth';

export default AuthenticationGenerator({

  propTypes: {
    router: PropTypes.object.isRequired

  redirect() {
    const { router } = this.props;

  isAuthenticated() {
    return auth.hasToken();