diff --git a/js/components/login_container.js b/js/components/login_container.js index 8c149d8c..ba8abd29 100644 --- a/js/components/login_container.js +++ b/js/components/login_container.js @@ -6,6 +6,8 @@ import Router from 'react-router'; import GlobalNotificationModel from '../models/global_notification_model'; import GlobalNotificationActions from '../actions/global_notification_actions'; +import UserStore from '../stores/user_store'; + import Form from './ascribe_forms/form'; import Property from './ascribe_forms/property'; @@ -15,6 +17,25 @@ import apiUrls from '../constants/api_urls'; let LoginContainer = React.createClass({ mixins: [Router.Navigation], + getInitialState() { + return UserStore.getState(); + }, + + componentDidMount() { + UserStore.listen(this.onChange); + }, + + componentWillUnmount() { + UserStore.unlisten(this.onChange); + }, + + onChange(state) { + this.setState(state); + if(this.state.currentUser && this.state.currentUser.email) { + this.transitionTo('pieces'); + } + }, + render() { return (