1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-09 13:21:44 +01:00

add redirect to login page if user is logged in

This commit is contained in:
Tim Daubenschütz 2015-06-25 11:49:45 +02:00
parent 0ce56a0821
commit 761138dbf6

View File

@ -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 (
<div className="ascribe-login-wrapper">
@ -31,9 +52,6 @@ let LoginContainer = React.createClass({
let LoginForm = React.createClass({
mixins: [Router.Navigation],
handleSuccess(){
let notification = new GlobalNotificationModel('Login successsful', 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification);