mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +01:00
add redirect to auth_component
This commit is contained in:
parent
6877f2c8a7
commit
0c6538df2f
@ -1,12 +1,16 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { History } from 'react-router';
|
||||||
|
|
||||||
import UserStore from '../../stores/user_store';
|
import UserStore from '../../stores/user_store';
|
||||||
import UserActions from '../../actions/user_actions';
|
import UserActions from '../../actions/user_actions';
|
||||||
|
|
||||||
|
|
||||||
export function AuthComponent(Component) {
|
export function AuthComponent(Component) {
|
||||||
return React.createClass({
|
return React.createClass({
|
||||||
|
mixins: [History],
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return UserStore.getState();
|
return UserStore.getState();
|
||||||
},
|
},
|
||||||
@ -16,6 +20,12 @@ export function AuthComponent(Component) {
|
|||||||
UserActions.fetchCurrentUser();
|
UserActions.fetchCurrentUser();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
componentDidUpdate() {
|
||||||
|
if(this.state.currentUser && !this.state.currentUser.email) {
|
||||||
|
this.history.pushState(null, '/login');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
UserStore.unlisten(this.onChange);
|
UserStore.unlisten(this.onChange);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user