mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +01:00
add redirect to login page if user is logged in
This commit is contained in:
parent
0ce56a0821
commit
761138dbf6
@ -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,15 +52,12 @@ let LoginContainer = React.createClass({
|
||||
|
||||
|
||||
let LoginForm = React.createClass({
|
||||
mixins: [Router.Navigation],
|
||||
|
||||
|
||||
handleSuccess(){
|
||||
let notification = new GlobalNotificationModel('Login successsful', 'success', 10000);
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
|
||||
/*Taken from http://stackoverflow.com/a/14916411 */
|
||||
/*
|
||||
/*
|
||||
We actually have to trick the Browser into showing the "save password" dialog
|
||||
as Chrome expects the login page to be reloaded after the login.
|
||||
Users on Stack Overflow claim this is a bug in chrome and should be fixed in the future.
|
||||
|
Loading…
Reference in New Issue
Block a user