title: React Router Authorization
body: <p>What are the best practices for authorization checking prior to a component mounting?</p>
  
  <p>I use react-router 1.x</p>
  
  <p>Here are my routes</p>
  
  <pre class="lang-jsx prettyprint-override"><code>React.render((
    &lt;Router history={History.createHistory()}&gt;
      &lt;Route path="/" component={Dashboard}&gt;&lt;/Route&gt;
      &lt;Route path="/login" component={LoginForm}&gt;&lt;/Route&gt;
    &lt;/Router&gt;
  ), document.body);
  </code></pre>
  
  <p>Here is my Dashboard component:</p>
  
  <pre class="lang-jsx prettyprint-override"><code>var Dashboard = React.createClass({
    componentWillMount: function () {
      // I want to check authorization here
      // If the user is not authorized they should be redirected to the login page.
      // What is the right way to perform this check?
    },
  
    render: function () {
      return (
        &lt;h1&gt;Welcome&lt;/h1&gt;
      );
    }
  });
  </code></pre>