<commit_before>import React from 'react';
import { connect } from 'react-redux';
import { pushState } from 'redux-router';

export function requireAuthentication(Component) {
		class AuthenticateComponent extends React.Component {

				constructor(props) {
						super(props);
				}

				componentWillMount() {
						if (!this.props.isAuthenticated) {
								this.props.dispatch(pushState(null, `/login?next=${this.props.location.pathname}`));
						}
				}

				render() {
						return (
							<Component {...this.props} />
						);
				}
		}

		AuthenticateComponent.propTypes = {
			dispatch: React.PropTypes.func.isRequired,
			isAuthenticated: React.PropTypes.bool,
			location: React.PropTypes.object
		};

		const mapStateToProps =
				(state) => ({
						token: state.user.token,
						isAuthenticated: state.user.authenticated
				});

		return connect(mapStateToProps)(AuthenticateComponent);
}
<commit_msg>reindent and make it work nicely with redux-simple-router's updatePath. Server side redirect still not fixed.<commit_after>import React, { PropTypes } from 'react';
import { connect } from 'react-redux';
import { updatePath } from 'redux-simple-router';

export function requireAuthentication(Component) {
  class AuthenticateComponent extends React.Component {

    constructor(props) {
      super(props);
    }

    componentWillMount() {
      const { isAuthenticated, dispatch } = this.props;
      if (!isAuthenticated) {
        dispatch(updatePath(`/login?next=${this.props.location.pathname}`));
      }
    }

    render() {
      return (
        <Component {...this.props} />
      );
    }
  }

  AuthenticateComponent.propTypes = {
    dispatch: PropTypes.func.isRequired,
    isAuthenticated: PropTypes.bool,
    location: PropTypes.object
  };

  function mapStateToProps(state) {
    return {
      token: state.user.token,
      isAuthenticated: state.user.authenticated
    };
  }

  return connect(mapStateToProps)(AuthenticateComponent);
};

{'fraction_non_alphanumeric': 0.12064613831398284, 'fraction_numerical': 0.0, 'mean_word_length': 3.2260127931769724, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6527014', 'n_tokens_mistral': 674, 'n_tokens_neox': 580, 'n_words': 110}