Autorización de React Router
¿Cuáles son las mejores prácticas para la verificación de autorizaciones antes del montaje de un componente?
Yo uso react-router 1.x
Aquí están mis rutas
React.render((
<Router history={History.createHistory()}>
<Route path="/" component={Dashboard}></Route>
<Route path="/login" component={LoginForm}></Route>
</Router>
), document.body);
Aquí está mi componente Tablero:
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 (
<h1>Welcome</h1>
);
}
});