Last active
August 29, 2015 14:21
-
-
Save nelix/99d4a3dad9b27e79ca1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Authenticated = function(isAuthenticated) { | |
return React.createClass({ | |
displayName: 'Authenticated', | |
statics: { | |
willTransitionTo(transition) { | |
if (!isAuthenticated()) { | |
transition.redirect('login'); | |
} | |
}, | |
}, | |
mixins: [Router.Navigation], | |
componentDidUpdate() { | |
if (!isAuthenticated()) { | |
this.transitionTo('/login'); | |
} | |
}, | |
render() { | |
if (!isAuthenticated()) { | |
return <span>'Redirecting to login'</span>; | |
} | |
return ( | |
<Router.RouteHandler | |
{...this.props} | |
/> | |
); | |
}, | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment