<commit_before>/** @jsx React.DOM */
var Routes = rf.router.Routes;
var Route = rf.router.Route;
var Link = rf.router.Link;

var Main = React.createClass({
  render: function() {
    return (
      <Routes handler={App}>
        <Route name="login" path="login" handler={Login}/>
        <Route name="logout" path="logout" handler={Logout}/>
        <Route name="about" path="about" handler={About}/>
        <Route name="dashboard" path="dashboard" handler={Dashboard}/>
      </Routes>
    );
  }
});

var App = React.createClass({

  getInitialState: function() {
    return {
      loggedIn: auth.loggedIn()
    };
  },

  setStateOnAuth: function(loggedIn) {
    this.setState({
      loggedIn: loggedIn
    });
  },

  componentDidMount: function() {
    auth.onChange = this.setStateOnAuth.bind(this);
    auth.login();
  },

  render: function() {
    // spans on logout because VD doesn't seem to think anything changed otherwise?
    // probably a bug in Link
    var loginOrOut = this.state.loggedIn ?
      <span><Link to="logout">Log out</Link></span> :
      <Link to="login">Sign in</Link>;
    return (
      <div>
        <h1>Auth User Flow</h1>
        <div>{loginOrOut}</div>
        <ul>
          <li><Link to="about">About</Link></li>
          <li><Link to="dashboard">Dashboard</Link> (authenticated)</li>
        </ul>
        {this.props.activeRoute}
      </div>
    );
  }
});

var AuthenticatedRoute = {
  statics: {
    lastInfo: null
  },

  componentDidMount: function() {
    if (!auth.loggedIn()) {
      AuthenticatedRoute.lastInfo = rf.router.getCurrentInfo();
      rf.router.replaceWith('login');
    }
  }
};

var Dashboard = React.createClass({

  mixins: [AuthenticatedRoute],

  render: function() {
    var token = auth.getToken();
    return (
      <div>
        <h1>Dashboard</h1>
        <p>You made it!</p>
        <p>{token}</p>
      </div>
    );<commit_msg>remove flash from authenticated route<commit_after>/** @jsx React.DOM */
var Routes = rf.router.Routes;
var Route = rf.router.Route;
var Link = rf.router.Link;

var Main = React.createClass({
  render: function() {
    return (
      <Routes handler={App}>
        <Route name="login" path="login" handler={Login}/>
        <Route name="logout" path="logout" handler={Logout}/>
        <Route name="about" path="about" handler={About}/>
        <Route name="dashboard" path="dashboard" handler={Dashboard}/>
      </Routes>
    );
  }
});

var App = React.createClass({

  getInitialState: function() {
    return {
      loggedIn: auth.loggedIn()
    };
  },

  setStateOnAuth: function(loggedIn) {
    this.setState({
      loggedIn: loggedIn
    });
  },

  componentWillMount: function() {
    auth.onChange = this.setStateOnAuth.bind(this);
    auth.login();
  },

  render: function() {
    // spans on logout because VD doesn't seem to think anything changed otherwise?
    // probably a bug in Link
    var loginOrOut = this.state.loggedIn ?
      <span><Link to="logout">Log out</Link></span> :
      <Link to="login">Sign in</Link>;
    return (
      <div>
        <h1>Auth User Flow</h1>
        <div>{loginOrOut}</div>
        <ul>
          <li><Link to="about">About</Link></li>
          <li><Link to="dashboard">Dashboard</Link> (authenticated)</li>
        </ul>
        {this.props.activeRoute}
      </div>
    );
  }
});

var AuthenticatedRoute = {
  statics: {
    lastInfo: null
  },

  componentWillMount: function() {
    if (!auth.loggedIn()) {
      this.render = function() { return <span/>};
      AuthenticatedRoute.lastInfo = rf.router.getCurrentInfo();
      rf.router.replaceWith('login');
    }
  }
};

var Dashboard = React.createClass({

  mixins: [AuthenticatedRoute],

  render: function() {
    var token = auth.getToken();
    return (
      <div>
        <h1>Dashboard</h1>
        <p>You made it!</p>
        <p>{token}</p>
      </div>
    );
{'fraction_non_alphanumeric': 0.16538263995891114, 'fraction_numerical': 0.002054442732408834, 'mean_word_length': 2.589861751152074, 'pattern_counts': {'":': 0, '<': 76, '<?xml version=': 0, '>': 76, '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': '5597725', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1299, 'n_words': 264}