1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 01:25:17 +01:00

Redirect from landing to collection if user is logged in

This commit is contained in:
vrde 2015-08-03 11:32:52 +02:00
parent 950e63b6d0
commit ac4a98fa16

View File

@ -6,9 +6,37 @@ import Router from 'react-router';
import ButtonLink from 'react-router-bootstrap/lib/ButtonLink'; import ButtonLink from 'react-router-bootstrap/lib/ButtonLink';
import ButtonGroup from 'react-bootstrap/lib/ButtonGroup'; import ButtonGroup from 'react-bootstrap/lib/ButtonGroup';
let Link = Router.Link; import UserStore from '../../../../stores/user_store';
import UserActions from '../../../../actions/user_actions';
let Landing = React.createClass({ let Landing = React.createClass({
mixins: [Router.Navigation],
getInitialState() {
return UserStore.getState();
},
componentDidMount() {
UserStore.listen(this.onChange);
UserActions.fetchCurrentUser();
},
componentWillUnmount() {
UserStore.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
// if user is already logged in, redirect him to piece list
if(this.state.currentUser && this.state.currentUser.email) {
// FIXME: hack to redirect out of the dispatch cycle
window.setTimeout(() => this.replaceWith('pieces'), 0);
}
},
render() { render() {
return ( return (
<div className="container"> <div className="container">