From 0c6538df2ff0b7206eff6d5cbdb33efaa1e29e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Tue, 6 Oct 2015 15:38:39 +0200 Subject: [PATCH] add redirect to auth_component --- js/components/ascribe_routes/auth_component.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/components/ascribe_routes/auth_component.js b/js/components/ascribe_routes/auth_component.js index d761230e..7c5ec8ed 100644 --- a/js/components/ascribe_routes/auth_component.js +++ b/js/components/ascribe_routes/auth_component.js @@ -1,12 +1,16 @@ 'use strict'; import React from 'react'; +import { History } from 'react-router'; import UserStore from '../../stores/user_store'; import UserActions from '../../actions/user_actions'; + export function AuthComponent(Component) { return React.createClass({ + mixins: [History], + getInitialState() { return UserStore.getState(); }, @@ -16,6 +20,12 @@ export function AuthComponent(Component) { UserActions.fetchCurrentUser(); }, + componentDidUpdate() { + if(this.state.currentUser && !this.state.currentUser.email) { + this.history.pushState(null, '/login'); + } + }, + componentWillUnmount() { UserStore.unlisten(this.onChange); },